Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
0 out of 2 rated this helpful - Rate this topic

Socket.ReceiveMessageFrom Method

Note: This method is new in the .NET Framework version 2.0.

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
)
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 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 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.

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.