This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: fix for socket timeouts (and a question about _Jv_select)
- To: Nic Ferrier <nferrier at tapsellferrier dot co dot uk>
- Subject: Re: fix for socket timeouts (and a question about _Jv_select)
- From: Cedric Berger <cedric at wireless-networks dot com>
- Date: Fri, 29 Jun 2001 21:59:03 -0700
- CC: java at gcc dot gnu dot org
- References: <sb3d3fcb.031@tapsellferrier.co.uk>
> But I can't understand the way it's called in natFileDescriptorPosix
> and natPlainSocketImpl because in those files 'n' is set to the socket
> number, the calls do this:
>
> int fd=...; //the file descriptor obtained from the call to open
> .
> .
> .
> //inside a method
> int result=_Jv_select(fd+1,&fds,NULL,NULL,timeout);
> .
> .
> .
>
> This would seem to be ridiculous! I don't see how using the
> filedescriptor number +1 could ever be the correct value of 'n' in a
> call to select.
>
> Indeed, I ran a test and the number being passed in (on my test) was
> 8. But it should be 1! no?
No. You do too much Windows development.
BSD doesn't define the first parameter of select like that:
For example, from the OpenBSD man page:
int
select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
struct timeval *timeout);
DESCRIPTION
select() examines the I/O descriptor sets whose addresses are passed in
readfds, writefds, and exceptfds to see if some of their descriptors are
ready for reading, are ready for writing, or have an exceptional condi-
tion pending, respectively. The first nfds descriptors are checked in
each set; i.e., the descriptors from 0 through nfds-1 in the descriptor
sets are examined. On return, select() replaces the given descriptor
sets with subsets consisting of those descriptors that are ready for the
requested operation. select() returns the total number of ready descrip-
tors in all the sets.
Cedric