Network/SocketImpl: Fix Send causing a SocketError_Internal status on non-blocking sockets
This commit is contained in:
parent
002d33f590
commit
453ca77c1b
|
|
@ -561,12 +561,24 @@ namespace Nz
|
|||
|
||||
int byteSent = send(handle, reinterpret_cast<const char*>(buffer), length, 0);
|
||||
if (byteSent == SOCKET_ERROR)
|
||||
{
|
||||
int errorCode = GetLastErrorCode();
|
||||
|
||||
switch (errorCode)
|
||||
{
|
||||
case EWOULDBLOCK:
|
||||
byteSent = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if (error)
|
||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
||||
*error = TranslateErrnoToResolveError(errorCode);
|
||||
|
||||
return false; //< Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sent)
|
||||
*sent = byteSent;
|
||||
|
|
@ -638,12 +650,24 @@ namespace Nz
|
|||
|
||||
int byteSent = sendto(handle, reinterpret_cast<const char*>(buffer), length, 0, reinterpret_cast<const sockaddr*>(nameBuffer.data()), bufferLength);
|
||||
if (byteSent == SOCKET_ERROR)
|
||||
{
|
||||
int errorCode = GetLastErrorCode();
|
||||
|
||||
switch (errorCode)
|
||||
{
|
||||
case EWOULDBLOCK:
|
||||
byteSent = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
if (error)
|
||||
*error = TranslateErrnoToResolveError(GetLastErrorCode());
|
||||
*error = TranslateErrnoToResolveError(errorCode);
|
||||
|
||||
return false; //< Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sent)
|
||||
*sent = byteSent;
|
||||
|
|
|
|||
|
|
@ -593,12 +593,25 @@ namespace Nz
|
|||
|
||||
int byteSent = send(handle, reinterpret_cast<const char*>(buffer), length, 0);
|
||||
if (byteSent == SOCKET_ERROR)
|
||||
{
|
||||
int errorCode = WSAGetLastError();
|
||||
switch (errorCode)
|
||||
{
|
||||
case WSAEWOULDBLOCK:
|
||||
{
|
||||
byteSent = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (error)
|
||||
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||
*error = TranslateWSAErrorToSocketError(errorCode);
|
||||
|
||||
return false; //< Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sent)
|
||||
*sent = byteSent;
|
||||
|
|
@ -666,12 +679,25 @@ namespace Nz
|
|||
|
||||
int byteSent = sendto(handle, reinterpret_cast<const char*>(buffer), length, 0, reinterpret_cast<const sockaddr*>(nameBuffer.data()), bufferLength);
|
||||
if (byteSent == SOCKET_ERROR)
|
||||
{
|
||||
int errorCode = WSAGetLastError();
|
||||
switch (errorCode)
|
||||
{
|
||||
case WSAEWOULDBLOCK:
|
||||
{
|
||||
byteSent = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (error)
|
||||
*error = TranslateWSAErrorToSocketError(WSAGetLastError());
|
||||
*error = TranslateWSAErrorToSocketError(errorCode);
|
||||
|
||||
return false; //< Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sent)
|
||||
*sent = byteSent;
|
||||
|
|
|
|||
Loading…
Reference in New Issue