Re: invalid argument in select() when peer socket is in FD_SET

看板FB_hackers作者時間14年前 (2011/08/01 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
Am 31.07.2011 17:45, schrieb Jilles Tjoelker: > On Sun, Jul 31, 2011 at 04:20:08PM +0200, Christoph P.U. Kukulies wrote: >> I posted this on freebsd-questions also but maybe the expert density >> isn't that high as here in "hackers". >> Since I think it may be a design or implementation issue in FreeBSDs' >> select(), I'm posting it here as well, >> hoping to get an experts' answer. >> I have written a small server to test TCP/IP roundtrip times of the >> packets in a proprietary protocol and while >> compiling and running this server on different platforms (Windows >> 7/cygwin, UbuntuLinux, FreeBSD 8.0 Release), I found >> that the server produces an error when the listening socket (on which >> the accept() is performed) is also >> member of the select() fd_set. >> On the other platforms the program works without error, just under >> FreeBSD I'm getting this "invalid argument" error. >> Comments appreciated (despite comments about the error checking logic >> [snip] >> tv.tv_sec = 0; >> tv.tv_usec = 5000000; /* 5 seconds */ >> [snip] >> n = select(nfds,&readfds, >> (fd_set *) NULL, /* not interested in write */ >> (fd_set *) NULL, /* ...or exceptions */ >> &tv); /* timeout */ > The number of microseconds in a struct timeval must be nonnegative and > less than one million (likewise, the number of nanoseconds in a struct > timespec must be nonnegative and less than 1000 million). > > FreeBSD checks this strictly in most functions. Ah, thanks. That's another plus for FreeBSD. Somehow I have been mislead during the development of the sample server that it escaped to me, that the timestruct was the culprit. Thanks again. saved me a lot of headaches. -- Christoph _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
文章代碼(AID): #1EDPXbdJ (FB_hackers)
文章代碼(AID): #1EDPXbdJ (FB_hackers)