So I have an application in C++ which has classes relating to network functionality. In a function I have made the socket for two clients that are meant to communicate with each other non-blocking via the following:
int check;
check = WSAAsyncSelect(sock, aWindow, 0, 0);
During the program loop each client program has functions which should send and recieve messages to/from one another. As mentioned the socket is non-blocking so the program loop runs indefinitely as it should do and each client sends messages to the other apparently fine via the following code:
socketConfirm = sendto(sock,
(char*) playerStats, sizeof(Message), 0, (SOCKADDR *) & toAddr, sizeof (toAddr));
However when the recieving function is called:
socketConfirm = recvfrom(sock, (char*)player2Stats, sizeof(Message), 0,
(sockaddr *) &fromAddr, &fromAddrSize);
And immediately after this the WSAGetLastError() function is called:
if(socketConfirm == SOCKET_ERROR)
{
error = WSAGetLastError();
}
An error code of 10022 is returned and clearly no message is being recieved by either client as the player representing each client on the screen of the other client does not move as inputs are applied and I was wondering if the reason that the messages were not being recieved could be deduced by this error code or if there is another problem that is causing the messages to not be recieved.
Aucun commentaire:
Enregistrer un commentaire