I am working on an event-based event-based application newtwork.
When the client has sent some data, and there is something to read on the socket, the network event FD_READ is generated.
Now, according to my understanding, when the server wants to write through the socket, an event should be created, that is, FD_WRITE. But how will this message be generated?
When there is something readable, FD_READ is automatically generated, but what about FD_WRITE when the server wants to write something?
Anyone who can help me with this confusion please?
The following is a snippet of code:
WSAEVENT hEvent = WSACreateEvent(); WSANETWORKEVENTS events; WSAEventSelect(newSocketIdentifier, hEvent, FD_READ | FD_WRITE); while(1) { //while(1) starts waitRet = WSAWaitForMultipleEvents(1, &hEvent, FALSE, WSA_INFINITE, FALSE); //WSAResetEvent(hEvent); if(WSAEnumNetworkEvents(newSocketIdentifier,hEvent,&events) == SOCKET_ERROR) { //Failure } else { //else event occurred starts if(events.lNetworkEvents & FD_READ) { //recvfrom() } if(events.lNetworkEvents & FD_WRITE) { //sendto() } } }
source share