Blocking and nonblocking client and server written in C.
There are several elements here for design of the socket server and client.
- Using blocking vs. non-blocking sockets
- Using forks vs. threads vs. asynchronous design (ties into whether to use blocking or non-blocking sockets).
- Test blocking-server:
$ gcc blocking/server.c -o server
$ ./server
Running the load-testing client:
$ time ./loadtester 0.02s user 0.03s system 4% cpu 1.030 total
- Testing non-blocking server:
$ gcc nonblocking/server.c -o server
$ ./server
Running the load-testing client:
$ cd loadtester/cmd/ && go build .
$ time ./loadtester
...
$ time ./loadtester 0.02s user 0.03s system 156% cpu 0.028 total
Meaning of the output for time
:
- [0.02s] user -> CPU time in user mode
- [0.03s] system -> CPU time in system mode
- 156% cpu -> % of cpu that this job got
- [0.028] total -> time from start to finish of call
- Work on nonblocking client based on notes here
- Change all code to incorporate proper C style (Gnu style: https://man.openbsd.org/style.9, OpenBSD style, Linux style)
- Start on port scanning code