select() ?

wu_yb (wu_yb@263.net)
Mon, 08 Nov 1999 14:13:33 +0800


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/