public static unsafe bool TryCompleteReceiveMessageFrom(SafeCloseSocket socket, byte[] buffer, int offset, int count, SocketFlags flags, byte[] socketAddress, ref int socketAddressLen, bool isIPv4, bool isIPv6, out int bytesReceived, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, out SocketError errorCode)
{
try
{
Interop.Error errno;
int received = ReceiveMessageFrom(socket, flags, buffer, offset, count, socketAddress, ref socketAddressLen, isIPv4, isIPv6, out receivedFlags, out ipPacketInformation, out errno);
if (received != -1)
{
bytesReceived = received;
errorCode = SocketError.Success;
return true;
}
bytesReceived = 0;
if (errno != Interop.Error.EAGAIN && errno != Interop.Error.EWOULDBLOCK)
{
errorCode = GetSocketErrorForErrorCode(errno);
return true;
}
errorCode = SocketError.Success;
return false;
}
catch (ObjectDisposedException)
{
// The socket was closed, or is closing.
bytesReceived = 0;
receivedFlags = 0;
ipPacketInformation = default(IPPacketInformation);
errorCode = SocketError.OperationAborted;
return true;
}
}