mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 09:25:49 +00:00
Fix handling of hostname with multiple candidate IP addresses when using alternate ports
This commit is contained in:
parent
a290ec032b
commit
5b2cf1b8f7
@ -326,6 +326,26 @@ int LiStartConnection(PSERVER_INFORMATION serverInfo, PSTREAM_CONFIGURATION stre
|
|||||||
|
|
||||||
Limelog("Resolving host name...");
|
Limelog("Resolving host name...");
|
||||||
ListenerCallbacks.stageStarting(STAGE_NAME_RESOLUTION);
|
ListenerCallbacks.stageStarting(STAGE_NAME_RESOLUTION);
|
||||||
|
LC_ASSERT(RtspPortNumber != 0);
|
||||||
|
if (RtspPortNumber != 48010) {
|
||||||
|
// If we have an alternate RTSP port, use that as our test port. The host probably
|
||||||
|
// isn't listening on 47989 or 47984 anyway, since they're using alternate ports.
|
||||||
|
err = resolveHostName(serverInfo->address, AF_UNSPEC, RtspPortNumber, &RemoteAddr, &RemoteAddrLen);
|
||||||
|
if (err != 0) {
|
||||||
|
// Sleep for a second and try again. It's possible that we've attempt to connect
|
||||||
|
// before the host has gotten around to listening on the RTSP port. Give it some
|
||||||
|
// time before retrying.
|
||||||
|
PltSleepMs(1000);
|
||||||
|
err = resolveHostName(serverInfo->address, AF_UNSPEC, RtspPortNumber, &RemoteAddr, &RemoteAddrLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We use TCP 47984 and 47989 first here because we know those should always be listening
|
||||||
|
// on hosts using the standard ports.
|
||||||
|
//
|
||||||
|
// TCP 48010 is a last resort because:
|
||||||
|
// a) it's not always listening and there's a race between listen() on the host and our connect()
|
||||||
|
// b) it's not used at all by certain host versions which perform RTSP over ENet
|
||||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47984, &RemoteAddr, &RemoteAddrLen);
|
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47984, &RemoteAddr, &RemoteAddrLen);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47989, &RemoteAddr, &RemoteAddrLen);
|
err = resolveHostName(serverInfo->address, AF_UNSPEC, 47989, &RemoteAddr, &RemoteAddrLen);
|
||||||
@ -333,6 +353,7 @@ int LiStartConnection(PSERVER_INFORMATION serverInfo, PSTREAM_CONFIGURATION stre
|
|||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
err = resolveHostName(serverInfo->address, AF_UNSPEC, 48010, &RemoteAddr, &RemoteAddrLen);
|
err = resolveHostName(serverInfo->address, AF_UNSPEC, 48010, &RemoteAddr, &RemoteAddrLen);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Limelog("failed: %d\n", err);
|
Limelog("failed: %d\n", err);
|
||||||
ListenerCallbacks.stageFailed(STAGE_NAME_RESOLUTION, err);
|
ListenerCallbacks.stageFailed(STAGE_NAME_RESOLUTION, err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user