From owner-freebsd-net@FreeBSD.ORG Tue Dec 2 02:02:49 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 50D58305 for ; Tue, 2 Dec 2014 02:02:49 +0000 (UTC) Received: from shell1.rawbw.com (shell1.rawbw.com [198.144.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 3BD0EBC3 for ; Tue, 2 Dec 2014 02:02:48 +0000 (UTC) Received: from eagle.yuri.org (c-73-162-232-245.hsd1.ca.comcast.net [73.162.232.245]) (authenticated bits=0) by shell1.rawbw.com (8.14.9/8.14.9) with ESMTP id sB222mQZ005393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 1 Dec 2014 18:02:48 -0800 (PST) (envelope-from yuri@rawbw.com) X-Authentication-Warning: shell1.rawbw.com: Host c-73-162-232-245.hsd1.ca.comcast.net [73.162.232.245] claimed to be eagle.yuri.org Message-ID: <547D1DC6.8030408@rawbw.com> Date: Mon, 01 Dec 2014 18:02:46 -0800 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: freebsd-net@freebsd.org Subject: Re: Can multiple apps listen for TCP on the same port? References: <547C5DD3.90604@rawbw.com> In-Reply-To: <547C5DD3.90604@rawbw.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Dec 2014 02:02:49 -0000 I figured it out. This is 'nc' from the base, imported from OpenBSD 5.6. nc has two flaws in its code: it listens with backlog=5 (not 1), and it doesn't close the listening socket after accept, only after client is done communicating. Fixing these two problems makes my app work. I first confused it with net/netcat from ports, which is totally different codebase, and isn't duplex. Looking into their code confused me into making original wrong assumptions. Thanks! Yuri