#!/bin/bash port=0 while [ $port -lt 1024 -o $port -gt 10000 ]; do port=$RANDOM done clang -Wall -Wextra -Werror mini_serv.c ./a.out "$port" 2>&1 & nc localhost "$port" 2>&1 & sleep 0.1 test1="on short line" test2="line 1 line 2 line 4" test3="one long line qqqqqqqqqqqqqq wwwwwwwwwwww eeeeeeeeeeeeee rrrrrrrrrrrrr tttttttttttt yyyyyyyyyyyyyyy uy iiiiiiiiiiiiiiiii oooooooo" echo "$test1" | nc localhost "$port" 2>&1 & sleep 0.1 echo "$test2" | nc localhost "$port" 2>&1 & sleep 0.1 echo "$test3" | nc localhost "$port" 2>&1 & sleep 0.1 for i in {1..3000} do nc localhost "$port" 2>&1 & kill -KILL $(pidof nc | tr ' ' '\n' | head -n1) done killall -q a.out nc