38 lines
578 B
Bash
38 lines
578 B
Bash
#!/bin/bash
|
|
|
|
port=0
|
|
while [ "$port" -lt 1024 -o "$port" -gt 10000 ]
|
|
do
|
|
port=$RANDOM
|
|
done
|
|
id=0
|
|
|
|
launch() {
|
|
while read -r line
|
|
do
|
|
echo "receiver $id: $line"
|
|
done < <(nc 127.0.0.1 "$port" 2>&1) &
|
|
((++id))
|
|
}
|
|
|
|
clang -Wall -Wextra -Werror mini_serv.c
|
|
./a.out "$port" 2>&1 &
|
|
launch
|
|
|
|
#launch
|
|
#launch
|
|
#launch
|
|
#kill -KILL $(pidof nc | tr ' ' '\n' | head -n1 )
|
|
#launch
|
|
#kill -KILL $(pidof nc | tr ' ' '\n' | head -n1 )
|
|
#launch
|
|
#kill -KILL $(pidof nc | tr ' ' '\n' | head -n1 )
|
|
|
|
for i in {1..30}
|
|
do
|
|
launch
|
|
kill -KILL $(pidof nc | tr ' ' '\n' | head -n1 )
|
|
done
|
|
|
|
killall -q a.out nc
|