StreamSocket.ConnectAsync(HostName, String) | connectAsync(HostName, String) method

Applies to Windows and Windows Phone

Starts an asynchronous operation on a StreamSocket object to connect to a remote network destination specified by a remote hostname and a remote service name.

Syntax


streamSocket.connectAsync(remoteHostName, remoteServiceName).done( /* Your success and error handlers */ );

Parameters

remoteHostName

Type: HostName

The hostname or IP address of the remote network destination. For Bluetooth RFCOMM, this is a MAC address.

remoteServiceName

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

The service name or TCP port number of the remote network destination. For Bluetooth RFCOMM, this is the Bluetooth address.

Return value

Type: IAsyncAction

An asynchronous connect operation on a StreamSocket object.

Remarks

The remoteHostName and remoteServiceName parameters must be provided. If the remoteHostName is null or the remoteServiceName is null or an empty string, an error will occur.

In a Windows Store app, the StreamSocket class supports connecting to a remote endpoint when proxies are required to complete the connection. This support for proxies is automatic and transparent to the app. For more detailed information, see the remarks on Support for proxies in the StreamSocket class reference.

In a Windows Phone Store app, the StreamSocket class does not provide automatic support for proxies.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

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

Other resources
How to set timeouts on socket operations (HTML)
How to set timeouts on socket operations (XAML)
Reference
ConnectAsync(EndpointPair)
ConnectAsync(EndpointPair, SocketProtectionLevel)
ConnectAsync(HostName, String, SocketProtectionLevel)
ConnectAsync(HostName, String, SocketProtectionLevel, NetworkAdapter)
HostName
StreamSocket

 

 

Show:
© 2014 Microsoft