A simple command-line chat application built in Java using socket connections and multithreading. This chat application allows multiple users to connect to a server and communicate by exchanging messages and sharing files.
-
Clone the Repository:
git clone https://github.com/Navnedia/Chat-Program.git cd Chat-Program
-
Compile the Code:
javac ChatClient.java javac ChatServer.java
-
Start the Chat Server: run the server by specifying your desired server listening port.
java ChatServer <port>
Example:
java ChatServer 6001
-
Connect Client to the Server: on the client machine, run the
ChatClient
application.-l
to specify the local port on the client to receive file requests.-p
the remote port of the chat server you wish to connect to.-s
(optional) the IP address of the chat server. Defaults tolocalhost
.
Note: If you are running multiple servers or clients on the same host, make sure none of your listen ports conflict.
java ChatClient -l <listening port number> -p <connect server port> [-s] [connect server address]
Example:
java ChatClient -l 6002 -p 6001 -s localhost
-
Client Username: you will be prompted to enter a username.
-
Start Messaging: Once connected, you will receive messages in the terminal, and you can send your own messages using the
M
menu option. -
File Sharing: Use a designated menu option
F
to request a file, then follow the prompts to select, the user that owns the file, and the name of the file you want (a file in the current working directory). -
Disconnect: you may disconnect at any time by using the
X
menu option or by terminating the program withCTRL + Z
orCTRL + C
.