Skip to content

m7amd777/net-cat-chat

Repository files navigation

NetCat Project

Description

NetCat in a Server-Client Architecture that can run in a server mode on a specified port listening for incoming connections, and it can be used in client mode, trying to connect to a specified port and transmitting information to the server.

Key Features:

  • TCP connection between server and multiple clients (relation of 1 to many).
  • A name requirement to the client.
  • Control connections quantity.
  • Clients are able to send messages to the chat room.
  • If a Client joins the chat, all the previous messages sent to the chat are uploaded to the new Client.
  • If a Client connects to the server or exits the char, the rest of the Clients are informed.
  • All Clients must receive the messages sent by other Clients.
  • If there is no port specified, the default port is 8989.

Project Structure

.
├── tcpServer                   # tcpServer Package.
│   ├── server.go               # main functionality.
│   ├── serverData.go           # package variables and data structure.
│   ├── utils.go                # utility functions.
│   ├── helper.go               # helper functions.
│   └── gucUI.go                # hanles terminal UI.
│
├── main.go                     # Entry point of the Go application.
├── main_test.go                # Handles unit tests for the application.
├── go.mod                      # Go module definition.
├── sum.go                      # Non standard imported packages.
├── linux.txt                   # linux logo for welcome message.
└── README.md                   # Current file being viewed.

Prerequisites

  1. Go: Make sure you have Go installed on your system. You can download it from the official Go website.

Technologies Used

  • Backend:
    • Go: Powers the server-side logic for listening to TCP connections and generating the chat room.

Files Description

  • server.go: Handles the main functionality of a TCP server, creates new server, handles clients connecting to the server and podcast messages to other clients.
  • serverData.go: Stores package variables and data structure.
  • utils.go: Utility functions like welcome() to welcome new clients, podcast() to podcast messages between clients.
  • helper.go: Helper functions like readFile() to read linux logo, writefile() to write messages in a log file.
  • gucUI.go: Handles terminal UI, organizes terminal view into small windows, using imported packages.
  • main.go: The main entry point of the application. It initializes the StartServer function.
  • main_test.go: Unit test to check if the server is working correctly and clients receive a welcome message and choose their nickname.

Usage

  1. Clone the repository (if you haven't already).

  2. Navigate to the project directory in your terminal.

  3. Run the application using the command:

    for default port 8989

    go run .

    or connects to a specific port

    go run ./main.go 2020

    or to run the test units

    go test
  4. Open another terminal window and connect to the server.

    // nc ip-address port
    nc lohostcal 8989
  5. Enter your name after recieving the welcome message.

  6. Repeat step 4 in another window or from different PC.

  7. Chat with other clients or enter -cn to change your nickname.

Author

About

A Netcat-inspired tool built for real-time, two-way chat over TCP. This project mimics Netcat’s raw socket capabilities but is focused on enabling simple peer-to-peer messaging between multiple users.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages