File: 12-wflag

package info (click to toggle)
netcat-openbsd 1.229-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,560 kB
  • sloc: ansic: 31,646; sh: 678; makefile: 68
file content (29 lines) | stat: -rw-r--r-- 771 bytes parent folder | download | duplicates (2)
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
start_client() {
    local in="$TEMPDIR/client.in" out="$TEMPDIR/client.out"
    mkfifo -- "$in" "$out"
    $NC ${NETCAT_DGRAM:+-u} "$@" "127.0.0.1" $PORT <"$in" >"$out" {LISTEN_IN}>&- {LISTEN_OUT}<&- & CLIENT_PID=$!
    exec {CONNECT_IN}>"$in" {CONNECT_OUT}<"$out"
    rm -f -- "$in" "$out"
}

# only test client, -w has no effect with -l
PORT=$(random_port)
PIPES="y" netcat_listen ${NETCAT_DGRAM:+-u} "127.0.0.1" $PORT

start_client -w3
greet server
greet client

# idleing...
wait $CLIENT_PID
${NETCAT_DGRAM:+kill_and_}wait $PID


# can't test wether -w timeouts TCP connections which can't be
# established, but we can do it for UDP
PORT=$(random_port)
if [ -n "$NETCAT_DGRAM" ]; then
    $NC ${NETCAT_DGRAM:+-u} -w1 "127.0.0.1" $PORT
fi

# vim: set filetype=bash :