This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: fix for socket timeouts (and a question about _Jv_select)


> 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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]