aboutsummaryrefslogtreecommitdiff
path: root/tests/tcpserver_reflect.sh
blob: d64beaf26e62cf8d0070adf35636f7fbed661e11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh


PIPEFILE="pipe.$$"

control_c()
# run if user hits control-c
{
  echo -en "\n*** Ouch! Exiting ***\n"
  rm -f ${PIPEFILE}
  exit $?
}

P=$1
PORT=$((P))
if [ ${PORT} -lt 1 ]; then
  echo "usage: $0 <port>" 1>&2
  exit 1
fi

echo "register Ctrl-C"
trap control_c SIGINT

echo "make pipe"
mknod ${PIPEFILE} p
echo "start server"
cat ${PIPEFILE} | nc -l -p ${PORT} > ${PIPEFILE}
echo "server quit"
rm ${PIPEFILE}