Click here to Skip to main content
11,923,046 members (63,674 online)
Rate this:
Please Sign up or sign in to vote.
See more: C Windows Visual-Studio , +
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 10-May-13 0:26am

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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151125.3 | 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