https://github.com/gotz1480/multithreaded-server-c
Multithreaded server implementation in C using websockets and POSIX threads
https://github.com/gotz1480/multithreaded-server-c
multi-threaded-server multithreaded-server multithreading posix-threads pthreads pthreads-api websockets websockets-server
Last synced: about 1 month ago
JSON representation
Multithreaded server implementation in C using websockets and POSIX threads
- Host: GitHub
- URL: https://github.com/gotz1480/multithreaded-server-c
- Owner: gotz1480
- License: gpl-3.0
- Created: 2021-11-08T02:13:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-09T04:51:01.000Z (over 3 years ago)
- Last Synced: 2025-04-04T13:13:19.926Z (about 2 months ago)
- Topics: multi-threaded-server, multithreaded-server, multithreading, posix-threads, pthreads, pthreads-api, websockets, websockets-server
- Language: C
- Homepage:
- Size: 44.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# multithreaded-server-c
## Description
Multithreaded server implementation in C using websockets and POSIX threads. A single-threaded server perfomance is compared with a multi-threaded server perfomance using the `time` tool.
## Installation
Run `make all` inside the folders "multithread" and "single-thread".
## Comparing perfomance
The bash script `manyclients.bash` will run, at the same time, 50 requests from the client to the server (check `client.c` for details).
### Single-threaded server
In "single-thread" folder, run `./server`. This will make the single-threaded server start listening (port 9002). Then, at another terminal, run `time ./manyclients.bash`. This will run 50 concurrent requests to the server. At the end of the script, the following results should appear, which should differ depending on your machine perfomance:
```
real 0m2.262s
user 0m0.004s
sys 0m0.004s
```### Multi-threaded server
For the multi-threaded server, go to the folder "multithread" and run `./server` to start the server. This will make the multi-threaded server start listening (port 9002). Then, at another terminal, run `time ./manyclients.bash`. This will run 50 concurrent requests to the server. At the end of the script, the following results should appear, which should differ depending on your machine perfomance:
```
real 0m0.018s
user 0m0.000s
sys 0m0.008s
```As seen from the results, the multi-threaded server was around 125 times faster than the single-threaded server.