Sign in to follow this  

WSAEventSelect method with UDP

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, i now how to implement the WSAEventSelect with using TCP sockets. IN the TCP verison i create an array of WSAEvents and array of the sockets that match with the events. here is an TCP exmaple: SOCKET socketArray[ MAX_AMOUNT ]; WSAEVENT eventArray[ MAX_AMOUNT ]; //// create and bind a listening sockets and create an event to go with the //// listening socket for accepting and closing while( TRUE ) { //// waits untill an event happens int Index = WSAWaitForMultipleEvents( MAX_AMOUNT, eventArray, FALSE, INFINITE, FALSE ) - WSA_WAIT_EVENT_0; /// from the smallest index of the event happened, loop through the rest incase more that one event happened at the same time for( int loop = Index; loop < MAX_AMOUNT; loop++ ) { WSAWaitForMultipleEvents( 1, &eventArray[loop], TRUE, 100, FALSE ); WSAEnumNetworkEvents( socketArray[Index], eventArray[Index], WSANETWORKEVENTS structure that inicates the event type ); //// then do the FD_ACCEPT or read, etc } } UDP is good for not having an array of sockets, you can just have the one to everything you want. So here are the questions: So can you use just one socket for this method? YOu would just call WSAWaitForMultipleEvents Do you still need an array of events or can you just use one? thanks [Edited by - themadme on December 8, 2008 11:49:17 AM]

Share this post


Link to post
Share on other sites
It's unclear what you're asking. If you're using TCP and WaitForMultipleObjects(), you will need to pass each socket into the call. If you're using UDP, then you only ever need one socket, and you can pass that socket into WaitForSingleObject() or WaitForMultipleObjects().

Note that on Windows 2000 and up, you can pass the socket directly; you don't need to go through the horrible WSAAsync socket API to bind an event to it. The socket itself is a waitable object.

Share this post


Link to post
Share on other sites

This topic is 3295 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this