Share via


StreamSocketListener.BindServiceNameAsync Method

Definition

Overloads

BindServiceNameAsync(String)

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

BindServiceNameAsync(String, SocketProtectionLevel)

Starts a bind operation on a StreamSocketListener to a local service name with a specified SocketProtectionLevel to set on any bound sockets.

BindServiceNameAsync(String, SocketProtectionLevel, NetworkAdapter)

Starts a socket bind operation on a StreamSocketListener to a local service name on a specified network adapter with a specified SocketProtectionLevel to set on any bound sockets.

BindServiceNameAsync(String)

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

public:
 virtual IAsyncAction ^ BindServiceNameAsync(Platform::String ^ localServiceName) = BindServiceNameAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction BindServiceNameAsync(winrt::hstring const& localServiceName);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction BindServiceNameAsync(string localServiceName);
function bindServiceNameAsync(localServiceName)
Public Function BindServiceNameAsync (localServiceName As String) As IAsyncAction

Parameters

localServiceName
String

Platform::String

winrt::hstring

The local service name or TCP port on which to bind the StreamSocketListener object. For Bluetooth RFCOMM, this parameter is the Bluetooth Service ID.

Returns

The asynchronous bind operation on a StreamSocketListener object.

Attributes

Remarks

The BindServiceNameAsync(String) method binds to the local IP addresses of all network interfaces on the local computer and to the local service name or TCP port specified in the localServiceName parameter. If the localServiceName parameter is an empty string, then the system will select the local TCP port on which to bind.

For Bluetooth RFCOMM, this method binds to the Bluetooth Service ID specified in the localServiceName parameter on all Bluetooth interfaces. A Bluetooth Service ID must be supplied to bind for Bluetooth.

The BindServiceNameAsync(String) method will fail if another app (another StreamSocketListener, for example) has already been bound to the local TCP port or Bluetooth Service ID specified in the localServiceName parameter.

See also

Applies to

BindServiceNameAsync(String, SocketProtectionLevel)

Starts a bind operation on a StreamSocketListener to a local service name with a specified SocketProtectionLevel to set on any bound sockets.

public:
 virtual IAsyncAction ^ BindServiceNameAsync(Platform::String ^ localServiceName, SocketProtectionLevel protectionLevel) = BindServiceNameAsync;
/// [Windows.Foundation.Metadata.Overload("BindServiceNameWithProtectionLevelAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction BindServiceNameAsync(winrt::hstring const& localServiceName, SocketProtectionLevel const& protectionLevel);
[Windows.Foundation.Metadata.Overload("BindServiceNameWithProtectionLevelAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction BindServiceNameAsync(string localServiceName, SocketProtectionLevel protectionLevel);
function bindServiceNameAsync(localServiceName, protectionLevel)
Public Function BindServiceNameAsync (localServiceName As String, protectionLevel As SocketProtectionLevel) As IAsyncAction

Parameters

localServiceName
String

Platform::String

winrt::hstring

The local service name or TCP port on which to bind the StreamSocketListener object. For Bluetooth RFCOMM, this parameter is the Bluetooth Service ID.

protectionLevel
SocketProtectionLevel

The protection level for encryption to set on any bound sockets.

Returns

The asynchronous bind operation on a StreamSocketListener object.

Attributes

Remarks

The [BindServiceNameAsync(String, SocketProtectionLevel) method binds to the local IP addresses of all network interfaces on the local computer and to the local service name or TCP port specified in the localServiceName parameter. For Bluetooth RFCOMM, this method binds to the Bluetooth Service ID specified in the localServiceName parameter on all Bluetooth interfaces. This method sets the protection level for encryption on any bound sockets to the protectionLevel parameter.

If the localServiceName parameter is an empty string, then the system will select the local TCP port on which to bind. A Bluetooth Service ID must be supplied to bind for Bluetooth.

The [BindServiceNameAsync(String, SocketProtectionLevel) method will fail if another app (another StreamSocketListener, for example) has already been bound to the local TCP port or Bluetooth Service ID specified in the localServiceName parameter.

The protectionLevel parameter must be set to PlainSocket for all sockets except those used over Bluetooth. When the socket is to be used over Bluetooth, the protectionLevel parameter can be set to PlainSocket, BluetoothEncryptionAllowNullAuthentication, or BluetoothEncryptionWithAuthentication. For more information, see the SocketProtectionLevel enumeration.

See also

Applies to

BindServiceNameAsync(String, SocketProtectionLevel, NetworkAdapter)

Starts a socket bind operation on a StreamSocketListener to a local service name on a specified network adapter with a specified SocketProtectionLevel to set on any bound sockets.

public:
 virtual IAsyncAction ^ BindServiceNameAsync(Platform::String ^ localServiceName, SocketProtectionLevel protectionLevel, NetworkAdapter ^ adapter) = BindServiceNameAsync;
/// [Windows.Foundation.Metadata.Overload("BindServiceNameWithProtectionLevelAndAdapterAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncAction BindServiceNameAsync(winrt::hstring const& localServiceName, SocketProtectionLevel const& protectionLevel, NetworkAdapter const& adapter);
[Windows.Foundation.Metadata.Overload("BindServiceNameWithProtectionLevelAndAdapterAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncAction BindServiceNameAsync(string localServiceName, SocketProtectionLevel protectionLevel, NetworkAdapter adapter);
function bindServiceNameAsync(localServiceName, protectionLevel, adapter)
Public Function BindServiceNameAsync (localServiceName As String, protectionLevel As SocketProtectionLevel, adapter As NetworkAdapter) As IAsyncAction

Parameters

localServiceName
String

Platform::String

winrt::hstring

The local service name or TCP port on which to bind the StreamSocketListener object. For Bluetooth RFCOMM, this parameter is the Bluetooth Service ID.

protectionLevel
SocketProtectionLevel

The protection level for encryption to set on any bound sockets.

adapter
NetworkAdapter

The network adapter on which to bind the StreamSocketListener object.

Returns

The asynchronous bind operation on a StreamSocketListener object.

Attributes

Remarks

The [BindServiceNameAsync(String, SocketProtectionLevel, NetworkAdapter) method binds to the local service name or TCP port specified in the localServiceName parameter on the network adapter specified in the adapter parameter on the local computer. For Bluetooth RFCOMM, this method binds to the Bluetooth Service ID specified in the localServiceName parameter if the adapter parameter is null. A Bluetooth Service ID must be supplied to bind for Bluetooth. If a network adapter is specified in the adapter parameter and the localServiceName parameter contains a Bluetooth Service ID, then this method will fail.

This method sets the protection level for encryption on any bound sockets to the protectionLevel parameter.

If the localServiceName parameter is an empty string, then the system will select the local TCP port on which to bind. If the adapter parameter is null for a TCP socket bind, an error will occur.

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

The [BindServiceNameAsync(String, SocketProtectionLevel, NetworkAdapter) method will fail if another app (another StreamSocketListener, for example) has already been bound to the local TCP port specified in the localServiceName parameter on the network adapter specified in the adapter parameter. For Bluetooth, this method will fail if another app (another StreamSocketListener, for example) has already been bound to the Bluetooth Service ID specified in the localServiceName parameter.

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

The protectionLevel parameter must be set to PlainSocket for all sockets except those used over Bluetooth. When the socket is to be used over Bluetooth, the protectionLevel parameter can be set to PlainSocket, BluetoothEncryptionAllowNullAuthentication, or BluetoothEncryptionWithAuthentication. For more information, see the SocketProtectionLevel enumeration.

See also

Applies to