CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: interrupting a select call in windoze

  1. #1
    Join Date
    Jun 2004
    Posts
    17

    Unhappy interrupting a select call in windoze

    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

  2. #2
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    Your last method should work; connecting to yourself. Walk over the code again.

  3. #3
    Join Date
    Jun 2004
    Posts
    17
    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..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)