https://github.com/samiyaalizaidi/multithreaded-client-server-in-c
A multi-threaded client-server application for concurrent file transfer with SHA256 data integrity verification.
https://github.com/samiyaalizaidi/multithreaded-client-server-in-c
client-server client-side concurrency-control file-transfer lock multithreading operating-system-learning operating-systems operating-systems-project server-side
Last synced: about 1 month ago
JSON representation
A multi-threaded client-server application for concurrent file transfer with SHA256 data integrity verification.
- Host: GitHub
- URL: https://github.com/samiyaalizaidi/multithreaded-client-server-in-c
- Owner: samiyaalizaidi
- License: mit
- Created: 2024-12-07T14:54:18.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-12-25T12:37:17.000Z (10 months ago)
- Last Synced: 2025-02-23T23:15:32.337Z (8 months ago)
- Topics: client-server, client-side, concurrency-control, file-transfer, lock, multithreading, operating-system-learning, operating-systems, operating-systems-project, server-side
- Language: C
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Concurrent File Transfer Application :bookmark_tabs:
This project implements a multi-threaded client-server application for file transfer using socket programming in C. The server splits requested files into segments and sends them concurrently, while the client reassembles the file and verifies its integrity using SHA256 checksums. MUTEX locks are employed on both sides to avoid race conditions and ensure thread-safe operations.
## Dependencies
Before you start, ensure the following dependencies are installed on your system:- **GCC Compiler**: To compile the source code.
- **Make**: For building the project using the Makefile.
- **OpenSSL Library**: Required for SHA256 checksum computations.
- Install OpenSSL on Ubuntu/Debian-based systems:
```bash
sudo apt-get update
sudo apt-get install libssl-dev
```
- For other systems, consult the OpenSSL installation guide for your package manager or platform.## Repository Structure
```
.
├── LICENSE
├── Makefile
├── README.md
├── client.c
├── server.c
└── tests.sh
```
- ``client.c``: The client program for requesting and reassembling files.
- ``server.c``: The server program for handling file requests.
- ``tests.sh``: A script for running automated tests.
## Installation and Usage1. **Clone the Repository**
To get started, clone the repository and navigate to the project directory:
```bash
git clone https://github.com/samiyaalizaidi/Multithreaded-Client-Server-in-C
cd Multithreaded-Client-Server-in-C
```2. **Build the Source Code**
Compile the source files using the ``Makefile``:
```bash
make build
```
3. **Run the Server**Start the server to listen for incoming file transfer requests:
```bash
./server
```
4. **Run the Client**In a separate terminal, run the client to request a file from the server:
```bash
./client
```
- ````: The name of the file you want to transfer.
- ````: The number of threads to use for concurrent file transfer.
5. **Run Automated Tests**To execute all automated tests, use the following command:
```bash
make run
```6. **Clean the Build Files**
Remove compiled binaries and other temporary files:
```bash
make clean
```
## Features
1. **Multi-Threaded File Transfer**: The server uses threads to transfer file segments concurrently.
2. **Data Integrity Checks**: The application computes SHA256 checksums to ensure data integrity during the transfer.
3. **Automated Testing**: Includes a script to test the application with various scenarios and file types.
## Limitations
- Occasionally, the client and server may hang during long or repeated runs. If this happens, restart both programs and try again.
- Ensure that the OpenSSL library is correctly installed, as it's critical for checksum computation.## Resources Referenced
- Socket programming tutorial: [GeeksforGeeks](https://www.geeksforgeeks.org/socket-programming-cc/)
- Multi-threading concepts: [YouTube Video](https://www.youtube.com/watch?v=Pg_4Jz8ZIH4)
- SHA256 computation using OpenSSL EVP API: [StackOverflow](https://stackoverflow.com/questions/34289094/alternative-for-calculating-sha256-to-using-deprecated-openssl-code) and [GitHub Issue](https://github.com/gluster/glusterfs/issues/2916)## Contributions
Code written by [Samiya Ali Zaidi](https://github.com/samiyaalizaidi).