PeerGraphListen function (p2p.h)
The PeerGraphListen function indicates that a peer graph should start listening for incoming connections.
Syntax
NOT_BUILD_WINDOWS_DEPRECATE HRESULT PeerGraphListen(
[in] HGRAPH hGraph,
[in] DWORD dwScope,
[in] DWORD dwScopeId,
[in] WORD wPort
);
Parameters
[in] hGraph
Specifies the peer graph to listen on.
[in] dwScope
Specifies the IPv6 scope to listen on. Valid values are identified in the following table. For more information about scope, see Link-Local and Site-Local Addresses.
[in] dwScopeId
Specifies the IPv6 scope ID to listen on. Specify zero (0) to listen on all interfaces of the specified scope.
[in] wPort
Specifies the port to listen on. Specify zero (0) to use a dynamic port. If zero (0) is specified, use PeerGraphGetNodeInfo to retrieve data.
Return value
Returns S_OK if the operation succeeds. Otherwise, the function returns one of the values identified in the following table.
Return code | Description |
---|---|
|
One of the parameters is not valid. |
|
There is not enough memory to perform the specified operation. |
|
The graph has never been synchronized. An application cannot listen until the peer graph has been synchronized. |
|
The handle to the peer graph is invalid. |
|
The graph must be initialized with a call to PeerGraphStartup—before using this function. |
Remarks
To be able to accept direct connections, a node must subscribe to the PEER_GRAPH_EVENT_DIRECT_CONNECTION event.
Before this function can be called, the application must call PeerGraphCreate or PeerGraphOpen.
Examples
The following code snippet shows how to use the PeerGraphListen function.
// g_hGraph is a handle to the Graph obtained from a previous successful call to PeerGraphCreate or PeerGraphOpen.
// dwScope should be set to the same scope used to create the graph. This example assumes the graph was created in the Global scope.
// g_usPort is the port to use for Graphing. Use zero to obtain a port dynamically.
HRESULT hr = PeerGraphListen(g_hGraph, PEER_GRAPH_SCOPE_GLOBAL, 0, g_usPort);
if (FAILED(hr))
{
// Insert your code to handle the error here.
}
else
{
// Insert your application specific code here.
}
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 |