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? :(
Anyone who can help me with this confusion please? :(
Following is the code snippet:
WSAEVENT hEvent = WSACreateEvent();
WSANETWORKEVENTS events;
WSAEventSelect(newSocketIdentifier, hEvent, FD_READ | FD_WRITE);
while(1)
{
waitRet = WSAWaitForMultipleEvents(1, &hEvent, FALSE, WSA_INFINITE, FALSE);
if(WSAEnumNetworkEvents(newSocketIdentifier,hEvent,&events) == SOCKET_ERROR)
{
}
else
{
if(events.lNetworkEvents & FD_READ)
{
}
if(events.lNetworkEvents & FD_WRITE)
{
}
}
}