diff --git a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs index 43172ab4..b9adb5cc 100644 --- a/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs +++ b/Ryujinx.HLE/HOS/Services/Sockets/Bsd/Impl/ManagedSocket.cs @@ -184,18 +184,35 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd public LinuxError Receive(out int receiveSize, Span buffer, BsdSocketFlags flags) { + LinuxError result; + + bool shouldBlockAfterOperation = false; + try { + if (Blocking && flags.HasFlag(BsdSocketFlags.DontWait)) + { + Blocking = false; + shouldBlockAfterOperation = true; + } + receiveSize = Socket.Receive(buffer, ConvertBsdSocketFlags(flags)); - return LinuxError.SUCCESS; + result = LinuxError.SUCCESS; } catch (SocketException exception) { receiveSize = -1; - return WinSockHelper.ConvertError((WsaError)exception.ErrorCode); + result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode); } + + if (shouldBlockAfterOperation) + { + Blocking = true; + } + + return result; } public LinuxError ReceiveFrom(out int receiveSize, Span buffer, int size, BsdSocketFlags flags, out IPEndPoint remoteEndPoint)