Export (0) Print
Expand All

Socket.ReceiveMessageFrom Method

Receives the specified number of bytes of data into the specified location of the data buffer, using the specified SocketFlags, and stores the endpoint and packet information.

Namespace: System.Net.Sockets
Assembly: System (in system.dll)

public int ReceiveMessageFrom (
	byte[] buffer,
	int offset,
	int size,
	ref SocketFlags socketFlags,
	ref EndPoint remoteEP,
	out IPPacketInformation ipPacketInformation
)
public int ReceiveMessageFrom (
	byte[] buffer, 
	int offset, 
	int size, 
	/** @ref */ SocketFlags socketFlags, 
	/** @ref */ EndPoint remoteEP, 
	/** @attribute OutAttribute() */ /** @ref */ IPPacketInformation ipPacketInformation
)
Not applicable.

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 typeCondition

ArgumentNullException

buffer is a null reference (Nothing in Visual Basic).

- or-

remoteEP is a null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

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.

SocketException

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.

ObjectDisposedException

The Socket has been closed.

NotSupportedException

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.

NoteNote:

The AddressFamily of the EndPoint used in ReceiveFrom needs to match the AddressFamily of the EndPoint used in SendTo.

NoteNote:

This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft