A simple Go server application that allows clients to send messages to the server, and the server responds with acknowledgments.
- Introduction
- Features
- Prerequisites
- Getting Started
- Project Structure
- Configuration
- Concurrent Handling
- Testing
- Error Handling
This Go server application demonstrates a basic client-server interaction where clients can send messages to the server, and the server responds with acknowledgments. The server handles incoming client connections concurrently using goroutines and ensures thread safety with a mutex.
- Clients can connect and send messages to the server.
- The server responds with acknowledgments for received messages.
- Concurrent handling of multiple client connections using goroutines.
- Synchronization with a mutex to prevent data races.
Before you begin, ensure you have met the following requirements:
- Go installed (version 1.23)
Follow these steps to get the project up and running.
Clone the repository:
git clone https://github.com/yasharth291/go-server.git
cd go-server
go run main.go
go-server/
├── server # Server implementation
├─server.go
├─client_handler.go
├── README.md # Project documentation (you are here)
├── main.go # entry file
Incoming client connections are handled concurrently using goroutines. Each client connection is processed in a separate goroutine, ensuring that multiple clients can connect and communicate with the server concurrently without conflicts. A mutex is used to prevent data races when handling client connections and messages.
Unit tests are included to validate the functionality of the server. You can run the tests using the following command:
go test
The application handles errors gracefully, including network-related errors. Error messages are logged to provide visibility into any issues that may occur during execution.