DatagramSocket.BindEndpointAsync(HostName, String) DatagramSocket.BindEndpointAsync(HostName, String) DatagramSocket.BindEndpointAsync(HostName, String) DatagramSocket.BindEndpointAsync(HostName, String) DatagramSocket.BindEndpointAsync(HostName, String) Method

Definition

Starts a bind operation on a DatagramSocket to a local hostname and a local service name.

public : IAsyncAction BindEndpointAsync(HostName localHostName, Platform::String localServiceName)
IAsyncAction BindEndpointAsync(HostName localHostName, winrt::hstring localServiceName) const;
public IAsyncAction BindEndpointAsync(HostName localHostName, String localServiceName)
Public Function BindEndpointAsync(localHostName As HostName, localServiceName As String) As IAsyncAction
Windows.Networking.Sockets.DatagramSocket.bindEndpointAsync(localHostName, localServiceName).done( /* Your success and error handlers */ );

Parameters

localHostName
HostName HostName HostName

The local hostname or IP address on which to bind the DatagramSocket object.

localServiceName
String String String

The local service name or UDP port on which to bind the DatagramSocket object.

Returns

An asynchronous bind operation on a DatagramSocket object.

Additional features and requirements

Capabilities
ID_CAP_NETWORKING [Windows Phone] privateNetworkClientServer internetClientServer

Remarks

The BindEndpointAsync method binds the DatagramSocket to the local hostname or IP address specified in the localHostName parameter and the local service name or UDP port number address specified in the localServiceName parameter. If the localHostName parameter is null, the system will select the local IP address on which to bind. If the localServiceName parameter is an empty string, the system will select the local UDP port on which to bind.

The BindEndpointAsync method will fail if another app using UDP (another DatagramSocket, for example) has already been bound to the local IP address and UDP port specified in the localHostName and localServiceName parameters.

Binding is essential for receiving data from any remote endpoint on a DatagramSocket, and is commonly done after a socket is created and the MessageReceived event has been set. The BindServiceNameAsync or BindEndpointAsync method is used to bind a DatagramSocket to a local service name or UDP port. The ConnectAsync methods will also result in a bind operation if the socket isn't already bound. Writing to a stream returned by one of the GetOutputStreamAsync methods will also result in a bind operation.

The BindServiceNameAsync and BindEndpointAsync methods are not needed in the following cases:

See also