This project consists of creating a client-server communication program using UNIX signals. The communication is established between a client and a server, with the server being started first and printing its process ID (PID). The client will take two parameters: the server's PID and the string to send. Upon receiving the string, the server will print it. Bitwise operations are used to efficiently transmit the data between the client and server.
The provided implementation includes two files: client.c
and server.c
, which represent the client and server functionalities, respectively.
client.c
main
: Takes two parameters (server PID and string to send) and calls theaction
function to send the string to the server using signals.
server.c
main
: Prints the server's PID, sets up signal handlers forSIGUSR1
andSIGUSR2
, and enters an infinite loop to listen for signals from clients.hdl
: Signal handler function to process received signals and reconstruct the transmitted character.
-
To compile the project, run the
make
command in the terminal. -
Start the server by running
./server
. The server will display its PID and wait for incoming signals. -
To send a string to the server, run the below command with the previously displayed server PID:
./client [server_PID] [string]