DatagramSocket.BindServiceNameAsync DatagramSocket.BindServiceNameAsync DatagramSocket.BindServiceNameAsync DatagramSocket.BindServiceNameAsync DatagramSocket.BindServiceNameAsync Method

Definition

Overloads

BindServiceNameAsync(String) BindServiceNameAsync(String) BindServiceNameAsync(String) BindServiceNameAsync(String) BindServiceNameAsync(String)

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

BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter)

Starts a bind operation on a DatagramSocket to a local service name and specific network interface.

BindServiceNameAsync(String) BindServiceNameAsync(String) BindServiceNameAsync(String) BindServiceNameAsync(String) BindServiceNameAsync(String)

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

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

Parameters

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 BindServiceNameAsync method binds to the local IP addresses of all network interfaces on the local computer on the local service name or UDP port specified in the localServiceName parameter. If the localServiceName parameter is an empty string, the system will select the local UDP port on which to bind.

The BindServiceNameAsync method will fail if another app using UDP (another DatagramSocket, for example) has already been bound to the local UDP port specified in the localServiceName parameter.

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. Writing to a stream returned by one of the GetOutputStreamAsync methods will also result in a bind operation if the socket isn't already bound.

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

See also

BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter) BindServiceNameAsync(String, NetworkAdapter)

Starts a bind operation on a DatagramSocket to a local service name and specific network interface.

public : IAsyncAction BindServiceNameAsync(Platform::String localServiceName, NetworkAdapter adapter)
IAsyncAction BindServiceNameAsync(winrt::hstring localServiceName, NetworkAdapter adapter) const;
public IAsyncAction BindServiceNameAsync(String localServiceName, NetworkAdapter adapter)
Public Function BindServiceNameAsync(localServiceName As String, adapter As NetworkAdapter) As IAsyncAction
Windows.Networking.Sockets.DatagramSocket.bindServiceNameAsync(localServiceName, adapter).done( /* Your success and error handlers */ );

Parameters

localServiceName
String String String

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

adapter
NetworkAdapter NetworkAdapter NetworkAdapter

The network adapter on which to bind the DatagramSocket object.

Returns

An asynchronous bind operation on a DatagramSocket object.

Remarks

The [BindServiceNameAsync(String, NetworkAdapter) method binds to a network interface specified in the adapter parameter and the local service name or UDP port specified in the localServiceName parameter on the local computer. If the localServiceName parameter is an empty string, the system will select the local UDP port on which to bind. If the adapter parameter is null, an error will occur.

The name resolution mechanism used by the [BindServiceNameAsync(String, NetworkAdapter) method is limited to the specified interface for the domain name system (DNS) namespace.

The BindServiceNameAsync method will fail if another app using UDP (another DatagramSocket, for example) has already been bound to the local UDP port specified in the localServiceName parameter on the same network interface.

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, but can't be limited to a specific network adapter. Writing to a stream returned by one of the GetOutputStreamAsync methods will also result in a bind operation if the socket isn't already bound, but can't be limited to a specific network adapter.

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

If the [BindServiceNameAsync(String, NetworkAdapter) method is used, the bind operation will limit incoming and outgoing multicast and unicast packets to the specified adapter.

Using the specified network adapter is on a best-effort basis. Among other configuration, systems with adapters configured in weak-host or forwarding modes may use an adapter other than the specified adapter.

See also