lkml.org 
[lkml]   [2002]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: poll() incompatability with POSIX.1-2001
> > 
> > When the connection has been established asynchronously, select() and poll()
> > shall indicate that the file descriptor for the socket is ready for writing."
> >
> > On linux-2.4 i noticed the following behaviour:
> >
> > On connect() success select() returns writability for the socket.
> > On connect() failure select() returns readability and writability for the
> > socket.
> >
> > This behaviour is according to the specification.
> >
> > However with poll() (with events=POLLIN|POLLOUT) i get the following
> > behaviour:
> >
> > On connect() success poll() returns POLLOUT in revents.
> > On connect() failure poll() returns POLLIN|POLLHUP|POLLERR in revents.
> >
> > It does not set the POLLOUT bit here..
>
> This is a failure to connect! The socket is therefore not ready for
> writing or reading -ever. This behavior may not be correct, not
> because of a failure to set the POLLOUT bit, but because the POLLIN
> bit is set. Check if this is really true. I can't duplicate this
> on 2.4.18 here because it's hard to get a deferred connect with my
> setup.
>


Hello!



I have done some experimentation.


First I used telnet to verify that the host xx.xx.xx.xx on port 80 is
up and listening. We verify that this is true.

Then, we run a test program.

The test program creates a TCP socket which will connect to a given host
on a given port then use the fcntl() call to set the non-blocking bit.

We then use connect() to connect to the host. We verify that the errno
is indeed EINPROGRESS.

We then use poll with an events member set to POLLIN | POLLOUT.


This is the result on a return from poll().

glee@orion ~/tmp $ ./poll-new -h xx.xx.xx.xx -p 80
connect
connect: INPROGRESS
poll: POLLOUT is set
terminating
glee@orion ~/tmp $


So, POLLOUT is set.


Now, we try to connect to an invalid port.

n ~/tmp $ ./poll-new -h xx.xx.xx.xx -p 4
connect
connect: INPROGRESS
poll: POLLERR set
poll: POLLHUP set
poll: POLLOUT is set
terminating
glee@orion ~/tmp $


So, POLLOUT is set.

By the way, what constants should be defined when you do a #include <poll.h>?


A lot of them are not defined, those listed in the poll() document on
the opengroup website, only POLLPRI and POLLIN, POLLOUT, POLLNVAL,
POLLHUP and POLLERR are defined.


POLLRDNORM, POLLRDBAND, POLLWRBAND, POLLWRNORM are not defined.


-- G.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:30    [W:0.099 / U:0.236 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site