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.

DatagramSocket.BindServiceNameAsync(String) | bindServiceNameAsync(String) method

Applies to Windows and Windows Phone

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

Syntax


datagramSocket.bindServiceNameAsync(localServiceName).done( /* Your success and error handlers */ );

Parameters

localServiceName

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

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

Return value

Type: IAsyncAction

An asynchronous bind operation on a DatagramSocket object.

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:

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

End of phone support

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Networking.Sockets
Windows::Networking::Sockets [C++]

Metadata

Windows.winmd

DLL

Windows.Networking.dll

Capabilities

internetClientServer
privateNetworkClientServer
ID_CAP_NETWORKING [Windows Phone]

See also

DatagramSocket
BindEndpointAsync
BindServiceNameAsync(String, NetworkAdapter)
DatagramSocketInformation

 

 

Show:
© 2014 Microsoft