Click to See Complete Forum and Search --> : interrupting a select call in windoze


jono
June 20th, 2004, 04:25 PM
hi everybody. im new here, but if anybody can help me w/ this, i promise to return. :-)

under unix it is possible (altho i havent tried it) to interrupt a blocking select() call by raising a signal in the process that owns the call. unfortunately, winsock doesnt have this capability.

the server i'm writing mainly connects to clients on localhost, but needs to respond in real time & not suck cycles. if i accept a connection from a new client, the request is serviced in a separate thread, and the server continues listening.

the problem is that once the new thread is active, i need to reset the fd_set so that select responds to i/o on that socket. a non blocking select call in a loop is too inefficient. what i need is to be able to cancel the current select call when the new thread is ready for input, at which point the server will fall thru the loop & do the appropriate book keeping.

DOES ANYBODY KNOW A WAY OF DOING THIS?

...ive tried the signal scenario. ive also tried calling select again, & even sending data from the server back to itself on another socket (im not sure why that doesnt work... any ideas?)

cheers
jono

j0nas
June 21st, 2004, 12:30 AM
Your last method should work; connecting to yourself. Walk over the code again.

jono
June 21st, 2004, 05:10 AM
yeah thanx. works good.

took me a while to get the sequence right & remember which socket is which. a bit schizophrenic, talking to yrself...

this sound like the right approach? it seems a little circuitous, but i just dont want to block new clients while the server creates & initializes the previous ones...

seems to work like clockwork, so..