PeerGraphOpenDirectConnection function (p2p.h)

The PeerGraphOpenDirectConnection function allows an application to establish a direct connection with a node in a peer graph. The connection can only be made if the node to which the application is connecting has subscribed to the PEER_GRAPH_EVENT_DIRECT_CONNECTION event. The application can then send data directly to another node. A call to this function is asynchronous.

Syntax

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

Parameters

[in] hGraph

Handle to a peer graph.

[in] pwzPeerId

Pointer to the unique ID of a user or node to connect to. This parameter is used to identify a specific user because multiple identities can be attached to the specified address.

[in] pAddress

Pointer to a PEER_ADDRESS structure that contains the address of the node to connect to.

[out] pullConnectionId

Receives the connection ID for the requested connection.

Return value

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

Return code Description
PEER_E_INVALID_GRAPH
The handle to the graph is invalid.
PEER_E_NOT_INITIALIZED
The graph must be initialized with a call to PeerGraphStartup—before using this function.

Remarks

A call to PeerGraphOpenDirectConnection is an asynchronous call. A PEER_GRAPH_EVENT_DIRECT_CONNECTION event is triggered to inform the application of the direct connection's success or failure. The actual status of the function's success or failure is given in the PEER_GRAPH_EVENT_DATA structure.

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

PeerGraphCloseDirectConnection

PeerGraphEnumConnections