1 out of 4 rated this helpful - Rate this topic

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


public:
IAsyncAction^ ConnectAsync(
  HostName^ remoteHostName, 
  String^ remoteServiceName
)

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.

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 (Windows Store apps using JavaScript and HTML)
How to set timeouts on socket operations (Windows Store apps using C#/VB/C++ and XAML)
Reference
ConnectAsync(EndpointPair)
ConnectAsync(EndpointPair, SocketProtectionLevel)
ConnectAsync(HostName, String, SocketProtectionLevel)
ConnectAsync(HostName, String, SocketProtectionLevel, NetworkAdapter)
HostName
StreamSocket

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.