-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_send.sh
executable file
·47 lines (34 loc) · 998 Bytes
/
test_send.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Define what server and client to use
server="./minitalk/server"
client="./minitalk/client"
# Define the message argument for the clients
msg="This is a test message"
# Start the server in the background
$server 2>&1 &
# Capture the server's PID using $!
server_pid=$!
echo "Server PID: $server_pid"
# Run the first client program with the captured PID and the message argument
($client "$server_pid" "$msg" 2>&1) | while IFS= read -r line; do
echo "
Client 1: $line"
done &
#Comment the next line out for multi send, not working consistently with my implementation sadly
: <<'END'
($client "$server_pid" "$msg" 2>&1) | while IFS= read -r line; do
echo "
Client 2: $line"
done &
($client "$server_pid" "$msg" 2>&1) | while IFS= read -r line; do
echo "
Client 3: $line"
done &
($client "$server_pid" "$msg" 2>&1) | while IFS= read -r line; do
echo "
Client 4: $line"
done &
#Comment the next line out for multi send
END
# Wait for all clients to finish
wait