Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ayoub0029/netcat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TCP Chat Server

Objectives

This project recreates the functionality of NetCat in a Server-Client architecture. It runs in server mode, listening for incoming connections on a specified port, and can be used in client mode to connect to the server and transmit information. The project emulates the NetCat utility, which reads and writes data across network connections using TCP.

The server-client application includes the following features:

  • TCP connection between a server and multiple clients (one-to-many relation).
  • A requirement for clients to provide a name upon connection.
  • Control over the number of simultaneous connections (up to 10).
  • Clients can send messages to the chat.
  • Empty messages are not broadcasted.
  • Messages are timestamped and prefixed with the sender’s name.
  • New clients receive all previous messages upon joining.
  • All clients are notified when a new client joins or leaves.
  • Clients that leave do not cause other clients to disconnect.
  • The server defaults to port 8989 if no port is specified; otherwise, it shows a usage message.

Usage

Run the server with default port:

$ go run .
Listening on port :8989

Run the server with a specified port:

$ go run . 2525
Listening on port :2525

If no port is specified, or if incorrect usage is attempted, the program will display:

[USAGE]: ./TCPChat [port]

Example

Starting the Server

Start the server on the default port:

$ go run .
Listening on port :8989

Connecting Clients

To connect a client using nc (NetCat):

$ nc localhost 8989

Interaction

Upon connection, you will see:

Welcome to TCP-Chat!
         _nnnn_
        dGGGGMMb
       @p~qp~~qMb
       M|@||@) M|
       @,----.JM|
      JS^\__/  qKL
     dZP        qKRb
    dZP          qKKb
   fZP            SMMb
   HZM            MMMM
   FqM            MMMM
 __| ".        |\dS"qML
 |    `.       | `' \Zq
_)      \.___.,|     .'
\____   )MMMMMP|   .'
     `-'       `--'
[ENTER YOUR NAME]:

After entering a valid name, you can start sending messages. Other clients connected to the server will see these messages with timestamps and the sender’s name.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages