PeerGroupOpenDirectConnection function (p2p.h)

The PeerGroupOpenDirectConnection function establishes a direct connection with another peer in a peer group.

Syntax

NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGroupOpenDirectConnection(
  [in]  HGROUP        hGroup,
  [in]  PCWSTR        pwzIdentity,
  [in]  PPEER_ADDRESS pAddress,
  [out] ULONGLONG     *pullConnectionId
);

Parameters

[in] hGroup

Handle to the peer group that hosts the direct connection. This handle is returned by the PeerGroupCreate, PeerGroupOpen, or PeerGroupJoin function. This parameter is required.

[in] pwzIdentity

Pointer to a Unicode string that contains the identity a peer connects to. This parameter is required.

[in] pAddress

Pointer to a PEER_ADDRESS structure that contains the IPv6 address the peer connects to. This parameter is required.

[out] pullConnectionId

Unsigned 64-bit integer that identifies the direct connection. This ID value cannot be assumed as valid until the PEER_GROUP_EVENT_DIRECT_CONNECTION event is raised and indicates that the connection has been accepted by the other peer. This parameter is required.

Return value

Returns S_OK if the operation succeeds. Otherwise, the function 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 available to complete the operation.
PEER_E_CONNECT_SELF
The connection failed because it was a loopback, that is, the connection is between a peer and itself.
PEER_E_NO_KEY_ACCESS
Access to the peer identity or peer group keys is denied. This is typically caused by an incorrect access control list (ACL) for the folder that contains the user or computer keys. This can happen when the ACL has been reset manually.
 

Cryptography-specific errors can be returned from the Microsoft RSA Base Provider. These errors are prefixed with CRYPT_* and defined in Winerror.h.

Remarks

Every direct connection opened with this function must be closed with PEER_GROUP_EVENT DATA structure has the status member of its component PEER_EVENT_CONNECTION_CHANGE_DATA structure set to PEER_CONNECTION_FAILED.

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 P2P.lib
DLL P2P.dll

See also

PEER_ADDRESS

PEER_EVENT_CONNECTION_CHANGE_DATA

PEER_GROUP_EVENT DATA

PEER_GROUP_EVENT_DIRECT_CONNECTION

PeerGroupCloseDirectConnection

PeerGroupCreate

PeerGroupJoin

PeerGroupOpen

PeerGroupSendData