#!/bin/bash # Test the connection is closed correctly # after all data are sent even if real client # already closed the connection port=8765 ip_listen=192.168.127.2 ip=192.168.127.1 set -e if ! nc -h &> /dev/null; then echo "This test require netcat to be installed" >&2 exit 1 fi # send a file quite long, check all is received dd if=../latency of=latency.test bs=1000 count=18 &> /dev/null killall latency &> /dev/null || true ../latency 10ms 4K > /dev/null & latency=$! sleep 0.2 nc -4l $ip_listen $port > out & receive=$! nc -4 $ip $port < latency.test ( sleep 5; kill $receive ) & sleep=$! disown $sleep wait $receive kill $latency || true kill $sleep || true if ! cmp out latency.test; then echo "Failure to send all data" >&2 exit 1 fi rm -f latency.test rm out echo Test succeeded