Combining netcat with fifos results in stuck queues/sbwait
Wayne Sierke
ws at au.dyndns.ws
Mon Sep 3 19:11:34 UTC 2012
I was hoping to establish a simple processing server using nc(1). After
finding numerous examples of combining netcat with fifos (named pipes) I
am unable to establish a reliable setup. E.g. following the example of
the canonical netcat server:
server:
#mkfifo backpipe
#nc -l 4242 < backpipe | tr -u "[:lower:]" "[:upper:]" >
backpipe
client:
#mkfifo frontpipe
#nc localhost 4242 < frontpipe > testfile.out &
#cat testfile.in > frontpipe
For any non-trivially small testfile I inevitably end up with the
processes at both ends stuck in sbwait.
I have managed to avoid the stuck condition by setting the TCP buffer
sizes at both ends:
nc -I 2048 -O 1024
with a resulting throughput of ~40kB/s (and a supplementary problem of
truncation).
There are other oddities, such as not using the fifo on the client end:
#nc -I 2048 -O 1024 localhost 4242 < testfile.in > testfile.out
&
also results in "stuck" processes.
So far I've tried on 8.2/8.3 i386 and amd64. The full implementation is
planned to use fifos for input and output along with fd redirection but
attempts using that have fared no better.
Can anyone provide a secret-sauce recipe for netcat/fifo success?
Thanks,
Wayne
More information about the freebsd-questions
mailing list