mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Don't check for errors from sendto() in the ping threads
This commit is contained in:
parent
83b1b17f87
commit
fe205d838d
@ -44,19 +44,17 @@ static void UdpPingThreadProc(void* context) {
|
|||||||
// Ping in ASCII
|
// Ping in ASCII
|
||||||
char pingData[] = { 0x50, 0x49, 0x4E, 0x47 };
|
char pingData[] = { 0x50, 0x49, 0x4E, 0x47 };
|
||||||
LC_SOCKADDR saddr;
|
LC_SOCKADDR saddr;
|
||||||
SOCK_RET err;
|
|
||||||
|
|
||||||
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
|
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
|
||||||
SET_PORT(&saddr, RTP_PORT);
|
SET_PORT(&saddr, RTP_PORT);
|
||||||
|
|
||||||
// Send PING every 500 milliseconds
|
// Send PING every 500 milliseconds
|
||||||
while (!PltIsThreadInterrupted(&udpPingThread)) {
|
while (!PltIsThreadInterrupted(&udpPingThread)) {
|
||||||
err = sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
|
// We do not check for errors here. Socket errors will be handled
|
||||||
if (err != sizeof(pingData)) {
|
// on the read-side in ReceiveThreadProc(). This avoids potential
|
||||||
Limelog("Audio Ping: sendto() failed: %d\n", (int)LastSocketError());
|
// issues related to receiving ICMP port unreachable messages due
|
||||||
ListenerCallbacks.connectionTerminated(LastSocketFail());
|
// to sending a packet prior to the host PC binding to that port.
|
||||||
return;
|
sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
|
||||||
}
|
|
||||||
|
|
||||||
if (firstReceiveTime == 0 && isSocketReadable(rtpSocket)) {
|
if (firstReceiveTime == 0 && isSocketReadable(rtpSocket)) {
|
||||||
// Remember the time when we got our first incoming audio packet.
|
// Remember the time when we got our first incoming audio packet.
|
||||||
|
@ -49,18 +49,16 @@ void destroyVideoStream(void) {
|
|||||||
static void UdpPingThreadProc(void* context) {
|
static void UdpPingThreadProc(void* context) {
|
||||||
char pingData[] = { 0x50, 0x49, 0x4E, 0x47 };
|
char pingData[] = { 0x50, 0x49, 0x4E, 0x47 };
|
||||||
LC_SOCKADDR saddr;
|
LC_SOCKADDR saddr;
|
||||||
SOCK_RET err;
|
|
||||||
|
|
||||||
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
|
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
|
||||||
SET_PORT(&saddr, RTP_PORT);
|
SET_PORT(&saddr, RTP_PORT);
|
||||||
|
|
||||||
while (!PltIsThreadInterrupted(&udpPingThread)) {
|
while (!PltIsThreadInterrupted(&udpPingThread)) {
|
||||||
err = sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
|
// We do not check for errors here. Socket errors will be handled
|
||||||
if (err != sizeof(pingData)) {
|
// on the read-side in ReceiveThreadProc(). This avoids potential
|
||||||
Limelog("Video Ping: send() failed: %d\n", (int)LastSocketError());
|
// issues related to receiving ICMP port unreachable messages due
|
||||||
ListenerCallbacks.connectionTerminated(LastSocketFail());
|
// to sending a packet prior to the host PC binding to that port.
|
||||||
return;
|
sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
|
||||||
}
|
|
||||||
|
|
||||||
PltSleepMsInterruptible(&udpPingThread, 500);
|
PltSleepMsInterruptible(&udpPingThread, 500);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user