Minitalk is a small data exchange program developed as part of the 42 School curriculum. It implements a communication channel between a client and a server using UNIX signals.
The purpose of this project is to create a communication program in C. The program consists of a server and a client. The server launches first and prints its PID. The client then takes the server's PID and a string as arguments, and sends the string to the server. The server receives the string and prints it.
The communication is achieved solely using two UNIX signals: SIGUSR1 and SIGUSR2.
- Server:
- Starts and prints its PID.
- Waits for incoming signals.
- Decodes the received signals into characters and prints the string.
- Client:
- Takes the server's PID and a string as arguments.
- Converts the string into a series of signals.
- Sends the signals to the server.
- Communication:
- Uses
SIGUSR1to represent a1bit. - Uses
SIGUSR2to represent a0bit. - Supports Unicode characters.
- Uses
- Acknowledgement: The server sends a signal back to the client to confirm that the message has been fully received.
- Unicode Support: Fully supports standard and extended ASCII characters (already implicit in the mandatory part but explicitly handled).
To compile the project, run the following command in the root directory:
makeThis will generate two executables: server and client.
To compile the bonus version (with message acknowledgement), run:
make bonusThis will generate server_bonus and client_bonus.
First, run the server. It will print its PID and wait for messages.
./serverOutput:
Pid: 12345
Open a new terminal window and run the client with the server's PID and the message you want to send.
./client 12345 "Hello, Minitalk!"The server will print:
Hello, Minitalk!
If you compiled with make bonus:
-
Start the bonus server:
./server_bonus
-
Run the bonus client:
./client_bonus <PID> "Hello, Bonus!"
The client will receive a confirmation signal and print:
Message confirmed by server!
- The communication relies on bitwise operations.
- Each character is broken down into 8 bits.
- The client iterates through each bit of every character in the string.
SIGUSR1is sent if the bit is1.SIGUSR2is sent if the bit is0.- The server reconstructs the character bit by bit. Once 8 bits are received, it prints the character and resets the bit counter.
usleepis used to ensure the server has enough time to process each signal.
Developed by sdadak for 42 Istanbul.