non-blocking accept() can hang.

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Feb 20 07:52:00 GMT 2013


On Feb 20 07:16, Tanaka Akira wrote:
> 2013/2/19 Corinna Vinschen
> >
> > I debugged your example code, and it can't work on Cygwin.  The problem
> > is that accept/connect on AF_LOCAL sockets performs a handshake
> > operation to make sure that the other side of the socket is a Cygwin
> > process as well, and to propagate credential information between
> > client and listener.  The way it's implemented right now requires that
> > both sides of the socket are responsive.  That's a safe thing for the
> > accept call here, but since there's neither a blocking connect, nor a
> > select or poll call waiting on the connecting side of the socket, nothing
> > goes forward.
> >
> > To get this code working, you have to use either AF_INET or AF_INET6
> > sockets, or you have to start a thread calling select or poll, so
> > there's an active function call which allows to perform the handshake
> > from the connecting side.
> 
> Thank you for the information.
> I'll use threads.

The most simple way to get a connected local socket is to use the
socketpair function, btw.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list