|
From: chenzero on 21 Jul 2008 10:42 Greetings, when using select() function, if no socet occurs an event, how to "gracefully return" from the select() ? that's , except to close socket brutely and I know that can use a timeout in the select(). the benefit of using "gracefully return" is making the app in a more controllable state. by far, I have read some document on the MSDN, but no other api provided for this. ideally, what I expected is an enhanced version of select() int select( int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timeval* timeout, HANDLE event // if event is signaled, select() returns immediatelly ); Could you help on this and maybe there is more better solution?thanks!chenzero
From: Remy Lebeau on 23 Jul 2008 03:39 "chenzero" <somewhere(a)earth.solar.com> wrote in message news:eewbv$z6IHA.4532(a)TK2MSFTNGP05.phx.gbl... > when using select() function, if no socet occurs an > event, how to "gracefully return" from the select() ? > except to close socket brutely and I know that can use > a timeout in the select(). Those are the only two choices select() offers. > ideally, what I expected is an enhanced version of select() What you are asking for is already available. Use WSACreateEvent(), WSAEventSelect() and WSAWaitForMultipleObjects() instead of select(). You can then use CreateEvent() to create a secondary event for your "graceful close", and have the code wait on both events at the same time. Gambit
From: chenzero on 23 Jul 2008 11:11 Hi Remy, Thank you very much. that's really what I looking for. and very nice to meet you here! I remeber that you also helped me in another place ? Regards, chenzero "Remy Lebeau" <no.spam(a)no.spam.com> д����Ϣ����:%23r$yYcJ7IHA.3696(a)TK2MSFTNGP04.phx.gbl... > > "chenzero" <somewhere(a)earth.solar.com> wrote in message > news:eewbv$z6IHA.4532(a)TK2MSFTNGP05.phx.gbl... > >> when using select() function, if no socet occurs an >> event, how to "gracefully return" from the select() ? >> except to close socket brutely and I know that can use >> a timeout in the select(). > > Those are the only two choices select() offers. > >> ideally, what I expected is an enhanced version of select() > > What you are asking for is already available. Use WSACreateEvent(), > WSAEventSelect() and WSAWaitForMultipleObjects() instead of select(). You > can then use CreateEvent() to create a secondary event for your "graceful > close", and have the code wait on both events at the same time. > > > Gambit >
From: Alan on 28 Jul 2008 02:50 On Jul 21, 3:42 pm, "chenzero" <somewh...(a)earth.solar.com> wrote: > Greetings, > when using select() function, if no socet occurs an event, > how to "gracefully return" from the select() ? You could include one end of a loopback connection in the list of sockets. To wakeup the thread doing the select just write to the other end of the connection. Pity Windows doesn't have a socketpair though.
From: chenzero on 28 Jul 2008 05:44 Hi Alan, also thanks! "Alan" <Alan.Bateman(a)sun.com> wrote in message news:fea69501-3676-4552-a265-10cdf2d5b9e1(a)a70g2000hsh.googlegroups.com... > On Jul 21, 3:42 pm, "chenzero" <somewh...(a)earth.solar.com> wrote: >> Greetings, >> when using select() function, if no socet occurs an event, >> how to "gracefully return" from the select() ? > You could include one end of a loopback connection in the list of > sockets. To wakeup the thread doing the select just write to the other > end of the connection. Pity Windows doesn't have a socketpair though.
|
Pages: 1 Prev: System Cache Working Set - Server 2008 x64 Next: Build problem with Windows Driver Kit |