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.
- 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.
.
├── 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.
- Go: Make sure you have Go installed on your system. You can download it from the official Go website.
- Backend:
- Go: Powers the server-side logic for listening to TCP connections and generating the chat room.
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.
-
Clone the repository (if you haven't already).
-
Navigate to the project directory in your terminal.
-
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 -
Open another terminal window and connect to the server.
// nc ip-address port nc lohostcal 8989
-
Enter your name after recieving the welcome message.
-
Repeat step 4 in another window or from different PC.
-
Chat with other clients or enter -cn to change your nickname.
- Ali Alqattan (alalqattan)
- Mohamed Badawi (mbadawi)