Networking Forums

Networking Forums > Computer Networking > Linux Networking > select() waiting for timeout before doing anything

Reply
Thread Tools Display Modes

select() waiting for timeout before doing anything

 
 
Frank de Bot
Guest
Posts: n/a

 
      12-07-2004, 09:56 AM
Hi,

I've written a tcp/ip client in C. For all reading I use select() The
idea behind this is, that the client has threads which can't read from
the socket all at one time, so a thread with the select call is
"instructing" other threads. When something is written from the server,
the client waits until the timeout of the select has been reached before
doing anything. There's only 1 FD is de fd_set and that's the socket.
Doesn't select "respond" when something is tried to be written on a fd?

Thanks in advanced,

Frank de Bot!
 
Reply With Quote
 
 
 
 
Peter T. Breuer
Guest
Posts: n/a

 
      12-07-2004, 12:07 PM
Frank de Bot <ppi_doenst@like_spam.searchy.net> wrote:
> I've written a tcp/ip client in C. For all reading I use select() The
> idea behind this is, that the client has threads which can't read from
> the socket all at one time, so a thread with the select call is
> "instructing" other threads. When something is written from the server,
> the client waits until the timeout of the select has been reached before
> doing anything. There's only 1 FD is de fd_set and that's the socket.
> Doesn't select "respond" when something is tried to be written on a fd?


Yes. Therefore your code is wrong.

(lacking telepathy and vision-at-a-distance of course I cannot tell
what is wrong with it - I would guess the fd+1 count is not fd+1,
but 1)

Peter
 
Reply With Quote
 
Frank de Bot
Guest
Posts: n/a

 
      12-07-2004, 07:18 PM
I've ran the process with strace and de fd_set is losing fd's :-S

[pid 9827] select(9, [0 8], NULL, NULL, {2, 500000}) = 1 (in [8], left
{2, 500000})
[pid 9827] select(9, [8], NULL, NULL, {2, 500000} <unfinished ...>

Could this be any clue what's wrong?

Frank


Peter T. Breuer wrote:
> Frank de Bot <ppi_doenst@like_spam.searchy.net> wrote:
>
>>I've written a tcp/ip client in C. For all reading I use select() The
>>idea behind this is, that the client has threads which can't read from
>>the socket all at one time, so a thread with the select call is
>>"instructing" other threads. When something is written from the server,
>>the client waits until the timeout of the select has been reached before
>>doing anything. There's only 1 FD is de fd_set and that's the socket.
>>Doesn't select "respond" when something is tried to be written on a fd?

>
>
> Yes. Therefore your code is wrong.
>
> (lacking telepathy and vision-at-a-distance of course I cannot tell
> what is wrong with it - I would guess the fd+1 count is not fd+1,
> but 1)
>
> Peter

 
Reply With Quote
 
Michael Fuhr
Guest
Posts: n/a

 
      12-07-2004, 08:05 PM
Frank de Bot <ppi_doenst@like_spam.searchy.net> writes:

> I've ran the process with strace and de fd_set is losing fd's :-S
>
> [pid 9827] select(9, [0 8], NULL, NULL, {2, 500000}) = 1 (in [8], left
> {2, 500000})
> [pid 9827] select(9, [8], NULL, NULL, {2, 500000} <unfinished ...>
>
> Could this be any clue what's wrong?


Are you initializing the descriptor set before each call to select()?
Neglecting to do so is a common mistake.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Configure ARP-Request-Timeout? (NOT Cache-Timeout!) Mario lzteM Linux Networking 0 07-28-2008 09:41 AM
Today is your day, your mountain is waiting, so get on your way. grazzy.cool@gmail.com Wireless Internet 0 02-20-2008 11:29 AM
still waiting for MAC code SoWeezy Broadband 6 03-28-2006 08:18 PM
select with timeout hangs when socket is closed eran borovik Linux Networking 0 10-19-2004 03:54 PM
What doens pppoe[3544]: Timeout waiting for PADO packets mean? Stefan Viljoen Linux Networking 8 06-19-2004 10:36 PM



1 2 3 4 5 6 7 8 9 10 11