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.
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:
sudo apt-get update sudo apt-get install libssl-dev
-
For other systems, consult the OpenSSL installation guide for your package manager or platform.
-
. ├── 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.
-
Clone the Repository
To get started, clone the repository and navigate to the project directory:
git clone https://github.com/samiyaalizaidi/Multithreaded-Client-Server-in-C cd Multithreaded-Client-Server-in-C -
Build the Source Code
Compile the source files using the
Makefile:make build
-
Run the Server
Start the server to listen for incoming file transfer requests:
./server
-
Run the Client
In a separate terminal, run the client to request a file from the server:
./client <file-name> <thread-count>
<file-name>: The name of the file you want to transfer.<thread-count>: The number of threads to use for concurrent file transfer.
-
Run Automated Tests
To execute all automated tests, use the following command:
make run
-
Clean the Build Files
Remove compiled binaries and other temporary files:
make clean
- Multi-Threaded File Transfer: The server uses threads to transfer file segments concurrently.
- Data Integrity Checks: The application computes SHA256 checksums to ensure data integrity during the transfer.
- Automated Testing: Includes a script to test the application with various scenarios and file types.
- 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.
- Socket programming tutorial: GeeksforGeeks
- Multi-threading concepts: YouTube Video
- SHA256 computation using OpenSSL EVP API: StackOverflow and GitHub Issue
Code written by Samiya Ali Zaidi.