The Minitalk project at 42 is designed to help students understand inter-process communication (IPC) by implementing a simple message-passing system using UNIX signals. This project involves creating a client-server architecture where the client sends a string message to the server, and the server prints it.
Minitalk relies on UNIX signals (SIGUSR1 and SIGUSR2) to transmit data between processes. The challenge is to encode characters as signals and ensure proper synchronization between the sender and receiver.
-
Implement a server and a client program.
-
The server must:
- Print its
$\color{crimson}{\textbf{PID}}$ (Process ID) when started. - Receive signals from the client and reconstruct the message.
- Display the received message correctly.
- Print its
-
The client must:
- Take two arguments:
server_pidandmessage. - Send the message character by character using
$\color{Darkorange}{\textbf{SIGUSR1}}$ and$\color{cyan}{\textbf{SIGUSR1}}$ . - Ensure reliable transmission of characters.
- Take two arguments:
The bonus part extends the project with:
- The ability to handle Unicode characters.
- Improved synchronization between the client and server.
- Sending acknowledgments from the server to confirm receipt of signals.
-
$\color{Darkorange}{\textbf{SIGUSR1}}$ (User-defined signal 1) and$\color{cyan}{\textbf{SIGUSR1}}$ (User-defined signal 2) are used to encode binary data. - Each character is sent bit by bit using these signals.
- The server must interpret the incoming signals and reconstruct the original message.
- The signal or sigaction function is used to set up handlers.
- The client converts each character into binary and sends the appropriate signals.
- The server listens for signals and reconstructs the characters.
To compile the project, use:
cc -Wall -Wextra -Werror server.c -o server
cc -Wall -Wextra -Werror client.c -o clientTo run the server:
./serverTo send a message from the client:
./client <server_pid> "Hello, World!"-
$\color{crimson}{\textbf{Incorrect signal handling}}$ leading to message corruption. -
$\color{crimson}{\textbf{Not handling PID properly}}$ , causing failed communication. -
$\color{crimson}{\textbf{Sending signals too quickly}}$ without proper synchronization. -
$\color{crimson}{\textbf{Ignoring edge cases}}$ like empty messages or special characters.
The Minitalk project is an excellent introduction to IPC and low-level signal handling in UNIX systems. By implementing this project, students gain a deeper understanding of how processes communicate and how to work with signals efficiently.