Select() did not select my socket
I use Fedora Core 1, kernel 2.4.22-1.2199.nptl. My program uses select() to poll five sockets, one is for accept() and others for read data. I set TCP_NO_DELAY by setsockopt and FIONBIO by ioctl. My program has 2 threads but it should not relate to my problem. The problem is my program sometimes block at select() but netstat shows that there are 29 bytes of data remaining in Recv-Q.
I had a similar problem before, make sure that you are refreshing your fd_set (second param in select()) for example
fd_set readfds, masterfds;
readfds = masterfds;
select(maxfd+1, readfds, NULL, NULL, NULL);
the comflicting line is "readfds = masterfds" you must put that before select if u want it to work, I mean you need a fd_set for reading, and another for refreshing the first one, this way if you make a FD_SET() you use the masterfds end then you copy it to the one you use for reading. This was my problem, maybe yours is diferent you should post a part of your code to let us see the problem.
I hope I helped you, good luck, Dam.
|All times are GMT -5. The time now is 04:44 PM.|