From owner-freebsd-net@FreeBSD.ORG Tue Dec 21 12:55:46 2010 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61A101065672 for ; Tue, 21 Dec 2010 12:55:46 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 33D858FC1C for ; Tue, 21 Dec 2010 12:55:46 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id C438F46B52; Tue, 21 Dec 2010 07:55:45 -0500 (EST) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 02E1A8A009; Tue, 21 Dec 2010 07:55:45 -0500 (EST) From: John Baldwin To: freebsd-net@freebsd.org Date: Tue, 21 Dec 2010 07:53:43 -0500 User-Agent: KMail/1.13.5 (FreeBSD/7.3-CBSD-20101102; KDE/4.4.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201012210753.43916.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Tue, 21 Dec 2010 07:55:45 -0500 (EST) X-Virus-Scanned: clamav-milter 0.96.3 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.9 required=4.2 tests=BAYES_00 autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bigwig.baldwin.cx Cc: Mohammad Hedayati Subject: Re: SOCK_STREAM socket in kernel space X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 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, 21 Dec 2010 12:55:46 -0000 On Tuesday, December 21, 2010 6:39:26 am Mohammad Hedayati wrote: > I'm about to use a char device for a kind of distributed processing, > so I've coded the open function as follows. The problem is that > soaccept returns 0 without populating the raddr. I've checked netstat, > everything seems to be fine, the socket is created, bound and the > state is LISTENING. Even the remote is connection is ESTABLISHED. But, > it cannot receive anything. it says that socket (sock variable) is > not connected. Yes, you are calling soaccept() on the wrong socket. You need to wait for a connection and dequeue the socket that connected and then call soaccept() on that new socket. Look at kern_accept() in sys/kern/uipc_syscalls.c. I wonder though if you wouldn't rather be calling soconnect instead? Do you really need to listen for new connections? -- John Baldwin