IOCP multiple socket completionports in same container
Posted
by
Ohmages
on Stack Overflow
See other posts from Stack Overflow
or by Ohmages
Published on 2012-09-03T03:36:01Z
Indexed on
2012/09/03
3:37 UTC
Read the original article
Hit count: 310
For the past couple of days I have been thinking about how to solve one of my problems I am facing, and I have tried to research the topic but don't really know what I can do.
I have 2 sockets in the same struct that both have the same completionport. Problem is, they both use different protocols. Is there a way that I can find out which socket got triggered? Their called game_socket, and client_socket
Example code would be something like...
while (true) {
error = GetQueuedCompletionStatus(CompletionPort, &BytesTransfered, (PULONG_PTR)&Key, &lpOverlapped, 0);
srvc = CONTAINING_RECORD ( lpOverlapped, client , ol );
if ( error == TRUE ) {
cout << endl << "SOCKET: [" << srvc->client_socket << "] TRIGGERED - WORKER THREAD" << endl;
cout << endl << "BytesTransfered: [" << BytesTransfered << "]" << endl;
if ( srvc->game_client triggered ) {
// .. this code
} else {
// .. this code
}
Any ideas our help would be appreciated :)
© Stack Overflow or respective owner