Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-07-2005, 11:56 PM   #1
LQ Newbie
Registered: May 2005
Posts: 1

Rep: Reputation: 0
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.
Old 05-08-2005, 12:20 AM   #2
LQ Newbie
Registered: Apr 2005
Posts: 26

Rep: Reputation: 15

I had a similar problem before, make sure that you are refreshing your fd_set (second param in select()) for example

main() {
int maxfd;
fd_set readfds, masterfds;
for(; {
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
select jhon Programming 5 11-01-2005 09:46 PM
C: Socket weirdness: select() -> fork() -> accept() maxfacta Programming 1 03-01-2005 01:33 PM
IPC in socket using select system call Gomathy Linux - Networking 0 01-28-2005 06:37 AM
Socket and Select() problems strikernzl Programming 2 09-01-2003 08:34 AM
what os to select kevinasr Linux - Newbie 2 05-18-2003 06:52 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration