- This is a multi-threaded chat server and client implementation in Java
- Multiple clients can connect to the server simultaneously (a new service thread handles each new client at server side)
- Server assigns a unique id to each client
- Following functionalities are available to each client:
Client X: <message>
delivers message to client with id XAll: <message>
delivers message to all present clients (aka broadcast)Client X,Y: <message>
delivers message to clients with ids X,Y onlyServer: List All
requests the server to reply with the list of all currently connected clients
src/
contains the source codesrc/Server.java
andsrc/Client.java
contain the server and client, respectivelysrc/ClientServiceThread.java
is theRunnable
(thread) used byServer
(one per client)
compile.sh
bash shell-script can be used to compile both server and client from source
- First compile by
cd
-ing into the root of this repository and then running command./compile.sh
- To start the server,
- Execute
java -classpath bin Server <port_no>
whereport_no
is the port number at which you want to start the server - For example, execute
java -classpath bin Server 1024
if server is to be started at port number 1024
- Execute
- To start a client (you can start and connect multiple clients),
- Execute
java -classpath bin Client <ip_addr> <port_no>
whereip_addr
,port_no
are IP address of server and port number, respectively - For example, execute
java -classpath bin Client 192.168.1.15 1024
is server's IP is 192.168.1.15 and port number is 1024
- Execute