From owner-freebsd-questions@FreeBSD.ORG Mon Sep 3 19:11:34 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B2B6E1065673 for ; Mon, 3 Sep 2012 19:11:34 +0000 (UTC) (envelope-from ws@au.dyndns.ws) Received: from ipmail05.adl6.internode.on.net (ipmail05.adl6.internode.on.net [IPv6:2001:44b8:8060:ff02:300:1:6:5]) by mx1.freebsd.org (Postfix) with ESMTP id F269F8FC1A for ; Mon, 3 Sep 2012 19:11:33 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAHj/RFCWZWdv/2dsb2JhbABFvCuDcG6IH5kgoRmSMAOITo4fhEuKO4Jz Received: from ppp103-111.static.internode.on.net (HELO lillith-iv.ovirt.dyndns.ws) ([150.101.103.111]) by ipmail05.adl6.internode.on.net with ESMTP; 04 Sep 2012 04:41:32 +0930 X-Envelope-From: ws@au.dyndns.ws X-Envelope-To: Received: from [172.17.17.134] (ws@predator-ii.buffyverse [172.17.17.134]) by lillith-iv.ovirt.dyndns.ws (8.14.4/8.14.4) with ESMTP id q83JBIoE036931 for ; Tue, 4 Sep 2012 04:41:18 +0930 (CST) (envelope-from ws@au.dyndns.ws) From: Wayne Sierke To: freebsd-questions Content-Type: text/plain; charset="ASCII" Date: Tue, 04 Sep 2012 04:41:21 +0930 Message-ID: <1346699481.13805.42.camel@predator-ii.buffyverse> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (lillith-iv.ovirt.dyndns.ws [172.17.17.142]); Tue, 04 Sep 2012 04:41:18 +0930 (CST) X-Scanned-By: MIMEDefang 2.72 on 172.17.17.142 X-Scanned-By: SpamAssassin 3.003002(2011-06-06) X-Scanned-By: ClamAV X-Spam-Score: -2.9 () ALL_TRUSTED,BAYES_00 Subject: Combining netcat with fifos results in stuck queues/sbwait X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Sep 2012 19:11:34 -0000 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