1emulate -L zsh
2setopt extendedglob cbases
3
4
5if [[ $# -ne 1 ]]; then
6    print "Usage: $0 port
7Listen on the given port; send anything that arrives to standard output." >&2
8    return 1
9fi
10
11local REPLY lfd afd
12if ! ztcp -l $1; then
13    print "Failed to listen on port $1" >&2
14    return 1
15fi
16
17lfd=$REPLY
18
19if ! ztcp -a $lfd; then
20    print "Failed to accept on fd $lfd" >&2
21    ztcp -c $lfd
22fi
23
24afd=$REPLY
25
26cat <&$afd
27
28ztcp -c $lfd
29ztcp -c $afd
30