Unix socket is made up of two file, written in C, defined as follow:
- server.c:
- open socket
- listen continuously socket, waiting connection from client
- receive message from client and print on standard output the message
- save received message in connection.txt, if file doesn't exist, server provides to create its
- send response to client
- client.c :
- open socket in order to communicate to server
- send message to server
- receive message from server
- close socket
- open file and write 10 random number in random.txt, if file doesn't exist, client provides to create its
- print content character by character
- read all file content and print buffer variable as string
Advanced Programming in the UNIX Environment Understand inet Developing C programs on Mac OS
Use Makefile to test code Compile: move in directory when the code is stored, with
cd PATH
Launch make command
make
Launch server
./Server_TCP
Launch client
./Client_TCP
Clean
make clean
- Benedetto Marco Serinelli - Initial work
The code is tested only on Ubuntu 18.04.3 LTS and macOS 10.13.