Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Dec 2010 07:53:43 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-net@freebsd.org
Cc:        Mohammad Hedayati <hedayati.mo@gmail.com>
Subject:   Re: SOCK_STREAM socket in kernel space
Message-ID:  <201012210753.43916.jhb@freebsd.org>
In-Reply-To: <AANLkTinL8HRex1FBi5fmbi216rW256mJc7nBu9J1%2B=OC@mail.gmail.com>
References:  <AANLkTinL8HRex1FBi5fmbi216rW256mJc7nBu9J1%2B=OC@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012210753.43916.jhb>