A simple chat server implemented in Go, allowing multiple clients to connect, exchange messages, and set nicknames. This reposity reference from smallchat.
- Multiple clients can connect to the server.
- Clients can set their nicknames using the
/nick
command. - Messages sent by clients are broadcasted to all connected clients.
- Supports messages with newlines.
- Go (Go 1.21 or higher recommended)
-
Change to the project directory:
cd go-chat-server
-
Build the server:
go build chat_server.go
-
Run the server:
./main
-
Open multiple terminal windows and use telnet or netcat to connect to the server:
nc localhost 7711
-
Set your nickname using the
/nick
command:/nick MyNickname
-
Start sending messages, including newlines:
Hello, everyone! This is a multiline message.
go run chat_server.go
-
Start the server, and it will begin listening for client connections.
-
Open multiple terminal windows and connect to the server using telnet or netcat.
-
Set nicknames for each client using the
/nick
command. -
Clients can send messages, and the server will broadcast these messages to all other clients.
Example:
arduinoCopy code [Client 1] /nick Alice [Client 2] /nick Bob [Client 1] Hello, Bob! [Client 2] Hi, Alice!
This project is licensed under the Apache-2.0 License.