System.Net.Sockets.SocketPal.ReceiveMessageFrom C# (CSharp) Method

ReceiveMessageFrom() private static method

private static ReceiveMessageFrom ( SafeCloseSocket socket, SocketFlags flags, byte buffer, int offset, int count, byte socketAddress, int &socketAddressLen, bool isIPv4, bool isIPv6, SocketFlags &receivedFlags, IPPacketInformation &ipPacketInformation, System.Net.Interop &errno ) : int
socket SafeCloseSocket
flags SocketFlags
buffer byte
offset int
count int
socketAddress byte
socketAddressLen int
isIPv4 bool
isIPv6 bool
receivedFlags SocketFlags
ipPacketInformation IPPacketInformation
errno System.Net.Interop
return int
        private static unsafe int ReceiveMessageFrom(SafeCloseSocket socket, SocketFlags flags, byte[] buffer, int offset, int count, byte[] socketAddress, ref int socketAddressLen, bool isIPv4, bool isIPv6, out SocketFlags receivedFlags, out IPPacketInformation ipPacketInformation, out Interop.Error errno)
        {
            Debug.Assert(socketAddress != null, "Expected non-null socketAddress");

            int cmsgBufferLen = Interop.Sys.GetControlMessageBufferSize(isIPv4, isIPv6);
            var cmsgBuffer = stackalloc byte[cmsgBufferLen];

            int sockAddrLen = socketAddressLen;

            Interop.Sys.MessageHeader messageHeader;

            long received;
            fixed (byte* rawSocketAddress = socketAddress)
            fixed (byte* b = buffer)
            {
                var sockAddr = (byte*)rawSocketAddress;

                var iov = new Interop.Sys.IOVector {
                    Base = &b[offset],
                    Count = (UIntPtr)count
                };

                messageHeader = new Interop.Sys.MessageHeader {
                    SocketAddress = sockAddr,
                    SocketAddressLen = sockAddrLen,
                    IOVectors = &iov,
                    IOVectorCount = 1,
                    ControlBuffer = cmsgBuffer,
                    ControlBufferLen = cmsgBufferLen
                };

                errno = Interop.Sys.ReceiveMessage(socket, &messageHeader, flags, &received);
                receivedFlags = messageHeader.Flags;
                sockAddrLen = messageHeader.SocketAddressLen;
            }

            ipPacketInformation = GetIPPacketInformation(&messageHeader, isIPv4, isIPv6);

            if (errno != Interop.Error.SUCCESS)
            {
                return -1;
            }

            socketAddressLen = sockAddrLen;
            return checked((int)received);
        }

Same methods

SocketPal::ReceiveMessageFrom ( Socket socket, SafeCloseSocket handle, byte buffer, int offset, int count, SocketFlags &socketFlags, Internals socketAddress, Internals &receiveAddress, IPPacketInformation &ipPacketInformation, int &bytesTransferred ) : SocketError