sendfile: added server implementation
[p2p-kernel-protocol.git] / sendfile / test.sh
1 #!/bin/bash
2
3 MODULE_NAME=af_p2pkp
4 MODULE_DIR=../module
5 CLIENT=client/client
6 SERVER=server/server
7 FILE=/tmp/testfile1
8 IP="127.0.0.1"
9 WAIT_TIME=5
10
11 LISTENERS_PORTS=(
12         60000
13 )
14
15
16 #use nc.traditional
17 echo 2 | update-alternatives --config nc &> /dev/null
18
19 [ -e $FILE ] || exit
20
21 #increase tests debugging
22 set -x
23
24 # listen for UDP packets on localhost, port 60000 (run in background)
25 for port in "${LISTENERS_PORTS[@]}"; do
26         $SERVER $IP $port testfile.$port &
27         pids="$pids $!"
28         ARGUMENTS="$IP $port $ARGUMENTS"
29 done
30
31 # wait for netcat to start listening
32 sleep 1
33
34 $CLIENT $FILE $ARGUMENTS
35
36 sleep $WAIT_TIME
37 # kill netcat
38 for pid in $pids; do
39         kill -9 $pid &> /dev/null
40 done