Retransmit UDP test packets a few times to be safe

This commit is contained in:
Cameron Gutman 2019-07-28 13:16:22 -07:00
parent 069b0c7656
commit b1a1352bbf

View File

@ -338,13 +338,19 @@ PortTestStatus TestPort(PSOCKADDR_STORAGE addr, int proto, int port, bool withSe
} }
else { else {
const char testMsg[] = "moonlight-test"; const char testMsg[] = "moonlight-test";
err = sendto(clientSock, testMsg, sizeof(testMsg), 0, (struct sockaddr*)&sin6, addrLen);
if (err == SOCKET_ERROR) { // Send several test packets to ensure a random lost packet doesn't make the test fail
fprintf(LOG_OUT, "sendto() failed: %d\n", WSAGetLastError()); for (int i = 0; i < 5; i++) {
closesocket(clientSock); err = sendto(clientSock, testMsg, sizeof(testMsg), 0, (struct sockaddr*)&sin6, addrLen);
closesocket(serverSock); if (err == SOCKET_ERROR) {
return PortTestError; fprintf(LOG_OUT, "sendto() failed: %d\n", WSAGetLastError());
} closesocket(clientSock);
closesocket(serverSock);
return PortTestError;
}
Sleep(200);
}
struct timeval timeout = {}; struct timeval timeout = {};
fd_set fds; fd_set fds;