From: Jogchem de Groot <bighawk@kryptology.org>
To: Geoffrey Lee <glee@gnupilgrims.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: poll() incompatability with POSIX.1-2001
Date: Tue, 15 Oct 2002 09:47:00 +0200 [thread overview]
Message-ID: <20021015074616.SQGS394.mail6-sh.home.nl@there> (raw)
In-Reply-To: <20021015033640.GA15553@anakin.wychk.org>
On Tuesday 15 October 2002 05:36, you wrote:
> 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.
Hello, on what version did you try this? I've tried this now on
Linux-2.4.18 and Linux-2.4.19 and both give the behaviour i described
previously (No POLLOUT set).
The simple test program i used is as follows:
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/select.h>
#include <errno.h>
main(int argc, char **argv) {
int sd,flags,stat,len=sizeof(int);
struct sockaddr_in sin;
struct pollfd pfd;
memset(&sin, 0, sizeof(sin));
sd = socket(AF_INET, SOCK_STREAM, 0);
fcntl(sd, F_SETFL, fcntl(sd, F_GETFL, 0) | O_NONBLOCK);
sin.sin_addr.s_addr = htonl(0x7f000001);
sin.sin_port = htons(atoi(argv[1]));
sin.sin_family = AF_INET;
if(connect(sd, (struct sockaddr *)&sin, sizeof(sin)) == -1 && errno ==
EINPROGRESS)
printf("connect returned EINPROGRESS\n");
pfd.fd = sd;
pfd.events = POLLIN | POLLOUT;
pfd.revents = 0;
poll(&pfd, 1, -1);
getsockopt(sd, SOL_SOCKET, SO_ERROR, &stat, &len);
printf("%s\n", stat ? "failed" : "succeeded");
printf("returned events: %hd\n", pfd.revents);
}
bighawk
next prev parent reply other threads:[~2002-10-15 7:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-14 14:58 poll() incompatability with POSIX.1-2001 Jogchem de Groot
2002-10-14 15:14 ` Richard B. Johnson
2002-10-14 17:13 ` Jogchem de Groot
2002-10-15 3:36 ` Geoffrey Lee
2002-10-15 7:47 ` Jogchem de Groot [this message]
2002-10-15 13:53 ` Geoffrey Lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021015074616.SQGS394.mail6-sh.home.nl@there \
--to=bighawk@kryptology.org \
--cc=glee@gnupilgrims.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).