Minitalk is a 42 project that involves creating a small data exchange program between a client and a server using UNIX signals. The main goal is to implement a simple messaging system where the client can send strings to the server, which the server then displays.
Key Concepts:
- UNIX Signals: Using SIGUSR1 and SIGUSR2 signals to transmit information.
- Signal Handling: Handling signals effectively to ensure data integrity.
- Process Communication: Establishing communication between two processes (client and server).
The Minitalk project focuses on:
- Learning about UNIX signals and how they can be used for inter-process communication.
- Understanding the principles of client-server architecture.
- Implementing robust signal handling to ensure that all messages are accurately transmitted and received.
- Gaining experience in managing asynchronous events in a C program.
To set up the project, follow these steps:
-
Clone the Repository:
git clone https://github.com/BenzThor/minitalk.git cd minitalk -
Compile the project:
The project includes a Makefile that handles the compilation process for both the server and client programs. To compile the project, simply run:
make
This command will generate the server and client executables in the project directory.
- To clean up the compiled files, you can use:
make clean
- To remove all compiled and object files, use:
make fclean
- To recompile the project from scratch, use:
make re
- To clean up the compiled files, you can use:
-
Start the server:
First, run the server. The server will display its Process ID (PID), which the client will need to send messages.
./server
The server will print its PID to the terminal.
-
Send a Message with the Client:
Use the client to send a message to the server. You need to provide the server's PID and the message as arguments:
./client [server_pid] "Your message here"Replace [server_pid] with the actual PID of the server, and replace "Your message here" with the message you want to send.
-
Example:
If the server's PID is 12345 and you want to send the message "Hello, Minitalk!", you would run:
./client 12345 "Hello, Minitalk!"The server should then display "Hello, Minitalk!" in its terminal.
- Signal Transmission: The client encodes each character of the message into a series of signals (SIGUSR1 and SIGUSR2) and sends them to the server.
- Signal Handling: The server decodes the received signals back into characters and prints the message to the terminal.
To test the Minitalk program:
- Start the server in one terminal.
- Use the client in another terminal to send messages to the server.
- Observe the server output to ensure it correctly displays the received messages.