Client Usage
The client requires exactly two arguments:<PID>- The server’s process ID (must be numeric)<message>- The string to send (must be non-empty)
Basic Examples
Quotes are required when your message contains spaces or special characters.
Complete Example
Multiple Messages
You can send multiple messages to the same server:- Server Output
- Client Commands
How It Works
The client sends messages by converting each character into binary and transmitting it bit-by-bit using UNIX signals:Timing Details
The client includes a 700 microsecond delay between each bit:- The server has time to process each signal
- Signals don’t get lost or merged
- Reliable character reconstruction
- Each character = 8 bits
- Each bit = 700 microseconds
- One character ≈ 5.6 milliseconds
- “Hello” (5 chars) ≈ 28 milliseconds
Error Messages
Wrong number of arguments
Wrong number of arguments
Wrong number of arguments (only PID)
Wrong number of arguments (only PID)
Invalid PID format
Invalid PID format
Signal sending failed
Signal sending failed
kill() system call failed. Common reasons:- Server PID doesn’t exist
- Server process has terminated
- Permission denied (trying to signal another user’s process)
- Verify the server is running:
ps aux | grep server - Check the correct PID from server output
- Restart the server if needed
Real-World Examples
Client Behavior
Silent Success
The client exits without output when the message is sent successfully. Check the server terminal to see the received message.
No Confirmation
The client doesn’t wait for server acknowledgment. It assumes success if
kill() returns 0.Bit-by-Bit
Messages are sent one bit at a time, starting from the most significant bit (MSB) of each character.
Fixed Delay
700 microseconds between each bit transmission ensures reliable delivery.
Testing Different Scenarios
- Rapid Messages
- Long Message
- Numbers Only
- With Newlines
Send multiple messages quickly:Server sees:
ABC (messages concatenated)Troubleshooting
Message not appearing on server
Message not appearing on server
Check:
- Server is running:
pgrep server - Using correct PID: Check server startup message
- Client exited without error message
- Server terminal is visible and active
Partial or garbled messages
Partial or garbled messages
Possible causes:
- Multiple clients sending simultaneously
- System under heavy load (signals delayed)
- Server was killed mid-transmission
- Send messages one at a time
- Increase the delay in client.c (change
usleep(700)to higher value) - Ensure stable system performance
Client hangs or takes too long
Client hangs or takes too long
The 700 microsecond delay is per bit:
- 1 character = 8 bits × 700μs = 5.6ms
- 100 characters = ~560ms
- Sending in smaller chunks
- Reducing the delay (may reduce reliability)