Skip to content

TRedzepagic/thread-forked-C-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thread-forked-C-server

C practice project - Multithreaded & Multiprocess C server and client pair

Program Description

This client-server pair uses two forms of concurrency (multithreading & multiprocess (forking)). We have a custom message format where the first byte of the buffer indicates the file name length (N bytes). The next N bytes are the filename, and the rest is the file.

The program uses TCP to first send over the filename length and the file name itself, then loops over the file in chunks of 512B after parsing its name length and name.

Multithreading and multiprocess techniques were employed.

Since this is a practice project any comments and criticisms are more than welcome, since the purpose of this program is to learn more about socket programming in C.

Usage

Compile with

gcc server.c -o serverThreaded -pthread (pthread will be undefined otherwise)
gcc server.c -o serverForked
gcc client.c -o client

Or any other name you like. Be sure to be in the respective folders.

First, start the server

./servername

Then, start the client with the filename as an argument. I've tried out two at the same time to test concurrency.

./client *filename*

Another terminal window

./client *filename2*

Resources

- Stack Overflow 
- Youtube (Jacob Sorber)
- University Lectures

About

C practice project - Multithreaded & Multiprocess C server

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages