A client-server communication program using UNIX signals for data transmission.
Minitalk is a project that explores inter-process communication using UNIX signals. It consists of a server that receives messages and a client that sends messages, communicating entirely through SIGUSR1 and SIGUSR2 signals. The server can handle multiple clients sequentially.
- Client-server architecture using signals only
- Bit-by-bit data transmission
- Unicode support
- Multiple client handling
- Acknowledgment system
- Error handling and timeout protection
- Displays its PID upon startup
- Receives messages from clients
- Prints received messages to stdout
- Handles multiple clients sequentially
- Sends messages to server using server PID
- Transmits data bit by bit using signals
- Receives acknowledgments from server
makeThis creates two executables: server and client.
- Clone the repository:
git clone https://github.com/bratzwitch/minitalk.git
cd minitalk- Compile the programs:
make- Start the server:
./serverThe server will display its PID (e.g., Server PID: 12345).
- Send a message from client:
./client [SERVER_PID] "Your message here"Terminal 1 (Server):
$ ./server
Server PID: 12345
Waiting for messages...
Hello from client!
Another messageTerminal 2 (Client):
$ ./client 12345 "Hello from client!"
Message sent successfully!
$ ./client 12345 "Another message"
Message sent successfully!SIGUSR1: Represents bit 0SIGUSR2: Represents bit 1
- Client converts each character to binary
- Sends each bit as a signal (SIGUSR1 or SIGUSR2)
- Server receives signals and reconstructs the character
- Server sends acknowledgment back to client
- Process repeats for each character
Client → Server: SIGUSR1 (0)
Client → Server: SIGUSR2 (1)
Client → Server: SIGUSR1 (0)
Client → Server: SIGUSR1 (0)
Client → Server: SIGUSR1 (0)
Client → Server: SIGUSR1 (0)
Client → Server: SIGUSR1 (0)
Client → Server: SIGUSR2 (1)
Server reconstructs: 'A'
server.c: Server implementationclient.c: Client implementationminitalk.h: Header file with prototypesutils.c: Helper functions (if any)Makefile: Compilation rules
void sig_handler(int sig, siginfo_t *info, void *context)
{
static int bit = 0;
static char c = 0;
static pid_t client_pid = 0;
// Handle signal and reconstruct character
// Send acknowledgment to client
}void send_char(pid_t server_pid, char c)
{
int bit;
for (bit = 7; bit >= 0; bit--)
{
if ((c >> bit) & 1)
kill(server_pid, SIGUSR2);
else
kill(server_pid, SIGUSR1);
usleep(100); // Small delay for reliability
}
}- Invalid PID validation
- Signal sending failures
- Server timeout handling
- Memory allocation errors
- Invalid arguments
Basic functionality:
./client [PID] "Hello, World!"
./client [PID] "Test with numbers: 12345"
./client [PID] "Special chars: !@#$%^&*()"Unicode support (bonus):
./client [PID] "Unicode: 你好 🌟 Émojis"Stress testing:
./client [PID] "$(cat large_file.txt)"If implemented:
- Unicode character support
- Acknowledgment system between client and server
- Multiple client handling with queuing
- GCC compiler
- Make
- UNIX-like system (Linux, macOS)
- Understanding of UNIX signals
SIGUSR1: User-defined signal 1 (represents bit 0)SIGUSR2: User-defined signal 2 (represents bit 1)SIGACTION: For advanced signal handling (bonus)
- Small delays between signals for reliability
- Acknowledgment system to prevent data loss
- Timeout handling for robustness
Viacheslav Moroz - 42 Student