lkml.org 
[lkml]   [1999]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectselect() ?
My program had 3 threads:

1. while(1) {
sk = accept( ... ) ;
insert sk into a socket queue
...
}

2. ...
select()
for ( every in socket queue )
if ( FD_SET( sk, ... ) )
read( sk, buf, len )
...

3. if ( some condition match on a socket )
close( sk )

Now I accept a new socket, such as sk = 19,
In thread 3, I detect a condition, and close(19), then I connect server
again, accept() return 19 (Now 19 is a free file slot).

But in thread2, the select() return, and read(19) return -1, errno is
"Bad file number".
It seem that after select(), thread 2 only know 19 is closed, but don't
know
a new 19 is open. ( I connect server about 1min after close a previous
socket,
so select() return 1 min after 19 is closed ).

Can any one help me !






-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.104 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site