Condividi tramite


IPEndPoint.Create Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Creates an endpoint from a socket address.

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

Syntax

'Declaration
Public Overrides Function Create ( _
    socketAddress As SocketAddress _
) As EndPoint
public override EndPoint Create(
    SocketAddress socketAddress
)

Parameters

Return Value

Type: System.Net.EndPoint
An EndPoint instance using the specified socket address.

Exceptions

Exception Condition
ArgumentException

The AddressFamily of socketAddress is not equal to the AddressFamily of the current instance.

-or-

socketAddress.Size < 8.

ArgumentNullException

The socketAddress parameter is nulla null reference (Nothing in Visual Basic).

Remarks

The Create method create a new EndPoint instance from the specified socket address.

Examples

The following example uses the specified SocketAddress to create an IPEndPoint.

' Recreate the connection endpoint from the serialized information.
Dim ipAddr As IPAddress = IPAddress.Loopback
Dim port As Integer = 80

Dim endpoint As IPEndPoint = new IPEndPoint(ipAddr,port)

outputBlock.Text &= "IPEndPoint.ToString(): "
outputBlock.Text &= endpoint.ToString()
outputBlock.Text &= vbCrLf
      // Recreate the connection endpoint from the serialized information.
      IPAddress ipAddr = IPAddress.Loopback;
      int port = 80;

      IPEndPoint endpoint = new IPEndPoint(ipAddr,port);

      outputBlock.Text += "IPEndPoint.ToString(): ";
      outputBlock.Text += endpoint.ToString();
      outputBlock.Text += "\n";

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.