Skip to content

Commit

Permalink
Give more time for the socket to be bound properly before being used …
Browse files Browse the repository at this point in the history
…(sometimes it takes a few seconds before the port detected correctly on receiver side). Fix #14130 most of the time, but may not be the best solution.
  • Loading branch information
anr2me committed Feb 15, 2021
1 parent fc457a4 commit 43d48af
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Core/HLE/sceNetAdhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,9 @@ static int sceNetAdhocPdpCreate(const char *mac, int port, int bufferSize, u32 f
// Switch to non-blocking for futher usage
changeBlockingMode(usocket, 1);

// Workaround to give time for the port to be bound before using the socket for sending to prevent MGS:PW from detecting a wrong source port during recvfrom
hleEatMicro(10000);

// Success
return hleLogDebug(SCENET, i + 1, "success");
}
Expand Down Expand Up @@ -3232,6 +3235,9 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
// Switch to non-blocking for futher usage
changeBlockingMode(tcpsocket, 1);

// Workaround to give time for the port to be bound before using the socket for sending to prevent receiver getting a wrong source port
hleEatMicro(10000);

// Initiate PtpConnect (ie. The Warrior seems to try to PtpSend right after PtpOpen without trying to PtpConnect first)
NetAdhocPtp_Connect(i + 1, rexmt_int, 1, false);

Expand Down Expand Up @@ -3798,6 +3804,9 @@ static int sceNetAdhocPtpListen(const char *srcmac, int sport, int bufsize, int
// Switch to non-blocking for futher usage
changeBlockingMode(tcpsocket, 1);

// Workaround to give time for the port to be bound before using the socket
hleEatMicro(10000);

// Return PTP Socket Pointer
return hleLogDebug(SCENET, i + 1, "success");
}
Expand Down

0 comments on commit 43d48af

Please sign in to comment.