PeerFinder.ConnectAsync | connectAsync method

Applies to Windows and Windows Phone

Connects to a peer discovered by a call to the FindAllPeersAsync method.

Syntax


public:
static IAsyncOperation<StreamSocket>^ ConnectAsync(
  PeerInformation^ peerInformation
)

Parameters

peerInformation

Type: PeerInformation

A peer information object representing the peer to connect to.

Return value

Type: IAsyncOperation<StreamSocket>

An asynchronous operation for connecting to a remote peer using the supplied StreamSocket object.

Remarks

You can obtain an instance of a PeerInformation object for a peer from a call to the FindAllPeersAsync method, or in a handler for the ConnectionRequested event.

If an app calls the ConnectAsync method to create a connection with a peer, the app will no longer advertise for a connection and will not be found by the FindAllPeersAsync method until the app calls the Close method to close the socket connection.

If you open a socket connection by calling the ConnectAsync method, only one socket connection can be open at a time for the computer. If your app, or another app calls the ConnectAsync method, then the existing socket connection will close.

An Access Denied exception will be thrown if you attempt to call ConnectAsync when your app is in the background.

Important  

The Proximity APIs do not provide authentication. You should avoid exchanging sensitive data with these APIs.

Windows Phone 8

Wi-Fi Direct is not supported on Windows Phone 8. For more information, see Proximity.

Examples

No code example is currently available or this language may not be supported.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

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

Metadata

Windows.winmd

Capabilities

proximity
ID_CAP_PROXIMITY [Windows Phone]
ID_CAP_NETWORKING [Windows Phone]

See also

PeerFinder
FindAllPeersAsync
PeerInformation
ConnectionRequested
Proximity and Tapping (JavaScript)
Proximity and Tapping (C#/VB/C++)
Samples
Proximity sample

 

 

Show:
© 2014 Microsoft