bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Non-blocking connects using poll


From: Travis Shirk
Subject: Non-blocking connects using poll
Date: Mon, 12 Mar 2001 17:00:33 -0700 (MST)

Hello,

I'm having some problems implementing non-blocking TCP connects
using poll (glibc 2.1.3).  I use fcntl to all the O_NONBLOCK
flag before calling connect.  I then poll for POLLIN | POLLOUT
for my specified timeout period.  poll returns 1, but the
revents flag contains POLLNVAL.  From the man page, I see that
this revent is caused by an unopened file descriptor, but
as far as I know the socket is opened; it was created with the
socket function (and it's value is 5).

I was looking through libc/sysdeps/unix/bsd/poll.c and saw that
poll is implemented in terms of __select and POLLNVAL is
set in the revents field when __select errors with an errno of
EBADF.

I'm using Unix Network Programming by W. Ricahrd Stevens as
a reference and his example implementation I don't see anything
being done between the creation of the socket, the non-blocking connect,
and the call to select that would "open" the socket.  I was going to try
and implement by code using select instead of poll, but is it really going
to matter since poll seems to use select anyway?  Furthermore, I'd like to
stick with poll since it avoids many of select's limitations.

I've tried polling sockfd and sockfd+1 and the resuls are the same.
I noticed Stevens using sockfd+1, but I have no idea what the purpose
of such a thing is??

Travis Shirk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]