PeerGraphConnect function (p2p.h)

The PeerGraphConnect function attempts to make a connection to a specified node in a peer graph. This function starts an asynchronous operation. The calling application must wait for a PEER_GRAPH_EVENT_NEIGHBOR_CONNECTION event to determine if the connection attempt is successful.

Syntax

NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGraphConnect(
  [in]  HGRAPH        hGraph,
  [in]  PCWSTR        pwzPeerId,
  [in]  PPEER_ADDRESS pAddress,
  [out] ULONGLONG     *pullConnectionId
);

Parameters

[in] hGraph

Handle to a peer graph.

[in] pwzPeerId

The unique ID of a peer to connect to at pAddress. Specify NULL to connect to any peer listening at a specified address in the same peer graph.

[in] pAddress

Pointer to a PEER_ADDRESS structure that identifies a node to connect to.

[out] pullConnectionId

Receives the pointer to an ULONGLONG that contains the connection ID. This ID can be used with the direct communication functions.

Return value

If the function call succeeds, the return value is S_OK. Otherwise, it returns one of the following values.

Return code Description
E_INVALIDARG
One of the parameters is not valid.
E_OUTOFMEMORY
There is not enough memory to perform a specified operation.
PEER_E_ALREADY_EXISTS
A neighbor connection to a specified node already exists.
PEER_E_INVALID_GRAPH
The handle to a peer graph is invalid.
PEER_E_NOT_INITIALIZED
A graph must be initialized with a call to PeerGraphStartup before using this function.

Requirements

Requirement Value
Minimum supported client Windows XP with SP2 [desktop apps only],Windows XP with SP1 with the Advanced Networking Pack forWindows XP
Minimum supported server None supported
Target Platform Windows
Header p2p.h
Library P2PGraph.lib
DLL P2PGraph.dll

See also

PEER_ADDRESS

PeerGraphGetEventData

PeerGraphListen

PeerGraphOpenDirectConnection

PeerGraphSendData