This project implements a simple TCP-based chat server in Go. The server allows multiple clients to connect, enabling them to communicate in real time. It demonstrates the use of Go's net
package for TCP connections and employs concurrency to handle multiple clients simultaneously.
- Customizable Port: Specify the port to run the server on, or use the default port
8989
. - Concurrent Clients: Handles multiple client connections using goroutines.
- Modular Design: Separation of concerns through the
functions
package, which manages client connections and other functionalities.
Build the project:
bash
Copy code
go build -o TCPChat
Run the server:
bash
Copy code
./TCPChat [port]
-
- Replace
[port]
with your desired port number. If omitted, the server defaults to port8989
.
- Replace
Connect to the server using a TCP client, such as netcat
:
bash
Copy code
nc localhost [port]
- Replace
[port]
with the server's port.
main.go
: The main entry point of the application, setting up the server and handling incoming connections.functions/ClientHandler.go
: Contains the logic for handling individual client connections.functions/ReadArt.go
: Auxiliary functions (likely related to ASCII art handling or other utilities).
- Standard Go libraries (
net
,os
,fmt
,log
).
Run the server:
bash
Copy code
./TCPChat 9090
Connect to the server:
bash
Copy code
nc localhost 9090
Start chatting!