Socket.ReceiveMessageFrom Method
Assembly: System (in system.dll)
'Declaration Public Function ReceiveMessageFrom ( _ buffer As Byte(), _ offset As Integer, _ size As Integer, _ ByRef socketFlags As SocketFlags, _ ByRef remoteEP As EndPoint, _ <OutAttribute> ByRef ipPacketInformation As IPPacketInformation _ ) As Integer 'Usage Dim instance As Socket Dim buffer As Byte() Dim offset As Integer Dim size As Integer Dim socketFlags As SocketFlags Dim remoteEP As EndPoint Dim ipPacketInformation As IPPacketInformation Dim returnValue As Integer returnValue = instance.ReceiveMessageFrom(buffer, offset, size, socketFlags, remoteEP, ipPacketInformation)
public int ReceiveMessageFrom ( byte[] buffer, int offset, int size, /** @ref */ SocketFlags socketFlags, /** @ref */ EndPoint remoteEP, /** @attribute OutAttribute() */ /** @ref */ IPPacketInformation ipPacketInformation )
JScript does not support passing value-type arguments by reference.
Parameters
- buffer
An array of type Byte that is the storage location for received data.
- offset
The position in the buffer parameter to store the received data.
- size
The number of bytes to receive.
- socketFlags
A bitwise combination of the SocketFlags values.
- remoteEP
An EndPoint, passed by reference, that represents the remote server.
- ipPacketInformation
An IPPacketInformation holding address and interface information.
Return Value
The number of bytes received.| Exception type | Condition |
|---|---|
| buffer is a null reference (Nothing in Visual Basic). - or- remoteEP is a null reference (Nothing in Visual Basic). | |
| offset is less than 0. -or- offset is greater than the length of buffer. -or- size is less than 0. -or- size is greater than the length of the buffer minus the value of the offset parameter. | |
| socketFlags is not a valid combination of values. -or- The LocalEndPoint property was not set. -or- The .NET Framework is running on an AMD 64-bit processor. -or- An error occurred when attempting to access the socket. See the Remarks section for more information. | |
| The Socket has been closed. | |
| The operating system is Windows 2000 or earlier, and this method requires Windows XP. |
The ReceiveMessageFrom method reads data into the buffer parameter, returns the number of bytes successfully read, and captures the remote host endpoint from which the data was sent, as well as information about the received packet.
Examine ipPacketInformation if you need to know if the datagram was sent using a unicast, multicast, or broadcast address.
Note |
|---|
| The AddressFamily of the EndPoint used in ReceiveFrom needs to match the AddressFamily of the EndPoint used in SendTo. |
Note |
|---|
| This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing. |
- SocketPermission for accepting connections from the network. Associated enumeration: Accept.
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Note