poll() under 10.3.9 is buggy (because it is a select wrapper) - but found work-a-round
poll() under 10.3.9 is buggy (because it is a select wrapper) - but found work-a-round
- Subject: poll() under 10.3.9 is buggy (because it is a select wrapper) - but found work-a-round
- From: Markus Hanauska <email@hidden>
- Date: Thu, 27 Sep 2007 11:49:10 +0200
Hello,
I found out a problem in 10.3.9, however, one you can easily work
around. Maybe someone else found it before, I haven found that in the
mailing list search, so I'm trying to share some knowledge/experience here.
In 10.4, there are two functions to poll on a set of sockets, select and
poll.
In 10.3, there are both functions, too, but poll is not really
supported, it is emulated using a wrapper around select.
It still works nicely... most of the time. But there are two issues the
wrapper is not taking care of (it could take care of, but I guess it's
rather a quick hack, then a good wrapper).
According to the man page, poll can only set errno to EFAULT, EINTR,
EINVAL. However, select can also set it to EBADF. So under 10.3.9 be
prepared for poll setting it to EBADF.
The second issue is: poll can mark sockets as ready for read, write,
having errors and having closed. Select can only mark them for ready to
read, write and having errors... it does not know the closed state. So
instead of marking a closed socket as closed, it will mark it as readable.
That means under 10.3.9, poll might mark a socket as readable, to tell
you that it has closed. So check readable sockets for still being open
or be prepared for an error and check if the error is that it has been
closed. Then your code will work nicely in 10.4 and 10.3 when using
poll() :-)
Regards,
Markus
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden