Click here to Skip to main content
11,790,613 members (60,200 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C Windows Visual-Studio Events , +
I am working on newtwork event based socket application.

When client has sent some data and there is something to be read on the socket, FD_READ network event is generated.

Now according to my understanding, when server wants to write over the socket, there must be an event generated i.e. FD_WRITE. But how this message will be generated?

When there is something available to be read, FD_READ is automatically generated but what about FD_WRITE when server wants to write something? Frown | :(

Anyone who can help me with this confusion please? Frown | :(

Following is the code snippet:

WSAEVENT hEvent = WSACreateEvent();
WSAEventSelect(newSocketIdentifier, hEvent, FD_READ | FD_WRITE);
      {   //while(1) starts
         waitRet = WSAWaitForMultipleEvents(1, &hEvent, FALSE, WSA_INFINITE, FALSE);
         if(WSAEnumNetworkEvents(newSocketIdentifier,hEvent,&events) == SOCKET_ERROR)
		{   //else event occurred starts
		    if(events.lNetworkEvents & FD_READ)
		    if(events.lNetworkEvents & FD_WRITE)
Posted 9-May-13 23:26pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

See[^] for a complete description of how these events are generated and consumed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 1,154
1 Maciej Los 825
2 KrunalRohit 686
3 ppolymorphe 660
4 CPallini 621

Advertise | Privacy | Mobile
Web02 | 2.8.1509028.1 | Last Updated 10 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100