This project is a multithreaded, multi-room chat application built using sockets in Go. It is designed as a practical assignment for a computer network undergraduate course.
- Multithreaded Server: The server is capable of handling multiple client connections simultaneously using goroutines.
- Multi-Room Chat: Users can create and join multiple chat rooms.
- Concurrent Clients: The client is designed to handle multiple messages concurrently, ensuring a smooth chat experience.
- Go (version 1.15 or later)
- A terminal or command prompt to run the server and client
-
Open a terminal or command prompt.
-
Navigate to the server directory.
-
Run the server using the following command:
go run server
The server will start and listen for incoming client connections.
-
Open a terminal or command prompt.
-
Navigate to the client directory.
-
Create or modify the
.env
file in the client directory and add theSERVER_IPADDR
variable with the IP address of the server:SERVER_IPADDR=<server-ip-address>
-
Run the client using the following command:
go run client
The client will connect to the server, allowing you to join and participate in chat rooms.
server/
: Contains the server code and logic for handling client connections and chat rooms.client/
: Contains the client code for connecting to the server and interacting with chat rooms.
Once the server and client are running:
- Enter your username
- Choose a room
- Start chatting!