Skip to content

GoSocketChat is a lightweight, efficient TCP chat application built in Go, designed for real-time messaging and seamless communication over network sockets.

Notifications You must be signed in to change notification settings

capricorn-32/GoSocketChat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Simple Chat Server

This project is a simple chat server implemented in Go. It allows multiple clients to connect, choose nicknames, join chat rooms, send messages, and see available rooms.

Features

  • Nicknames: Clients can set their nicknames.
  • Join Rooms: Clients can join existing chat rooms or create new ones.
  • Message Rooms: Clients can send messages to all members of a room.
  • List Rooms: Clients can list all available rooms.
  • Quit: Clients can quit the server gracefully.

Getting Started

Prerequisites

  • Go (version 1.16+)

Installation

  1. Clone the repository:

    git clone https://github.com/seniorLikeToCode/GoSocketChat.git
    cd GoSocketChat
  2. Build the server:

    go build -o main.go
  3. Run the server:

    ./main

The server will start and listen for connections on port 5000.

Usage

Connecting to the Server

You can use telnet or netcat to connect to the server:

telnet localhost 5000

or

nc localhost 5000

Commands

Once connected, you can use the following commands:

  • /nick NAME: Set your nickname.

    /nick mynickname
  • /join ROOM_NAME: Join a room or create a new one if it doesn't exist.

    /join room1
  • /msg MSG: Send a message to the current room.

    /msg Hello everyone!
  • /rooms: List all available rooms.

    /rooms
  • /quit: Quit the server.

    /quit

Example Session

telnet localhost 5000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
/nick Alice
all right, I will call you Alice
/join room1
Welcome to room1
/msg Hello, room1!
Alice: Hello, room1!
/rooms
available rooms: room1
/quit
sad to see you go :(
Connection closed by foreign host.

Logging

The server logs all connections, disconnections, and errors to the standard output.


About

GoSocketChat is a lightweight, efficient TCP chat application built in Go, designed for real-time messaging and seamless communication over network sockets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages