printf("Cannot bind to server: %s(%d)\n", strerror(errno), errno);
return -1;
}
- argv += 2;
printf("Bound to: %s:%s\n", argv[0], argv[1]);
+ argv += 2;
err = read(sock, argv[0], sizeof(argv[0]));
if (err < 0) {
#!/bin/bash
MODULE_NAME=af_p2pkp
-MODULE_DIR=../../module
-CLIENT=./client
+MODULE_DIR=../module
+CLIENT=client/client
+SERVER=server/server
+IP="127.0.0.1"
LISTENERS_PORTS=(
60000
60001
- 60002
)
#increase tests debugging
set -x
+# insert module, causing the message to be sent
+insmod $MODULE_DIR/$MODULE_NAME.ko
+
# listen for UDP packets on localhost, port 60000 (run in background)
-for listener in "${LISTENERS_PORTS[@]}"; do
- netcat -l -u -p $listener &
+for port in "${LISTENERS_PORTS[@]}"; do
+ $SERVER $IP $port testfile.$port &
pids="$pids $!"
- ARGUMENTS="127.0.0.1 $listener $ARGUMENTS"
+ ARGUMENTS="$IP $port $ARGUMENTS"
done
# wait for netcat to start listening
sleep 1
-# insert module, causing the message to be sent
-insmod $MODULE_DIR/$MODULE_NAME.ko
-
$CLIENT $ARGUMENTS
-# remove module
-rmmod $MODULE_NAME
-
# kill netcat
for pid in $pids; do
- kill $pid &> /dev/null
+ wait $pid &> /dev/null
done
+
+# remove module
+rmmod $MODULE_NAME
+