Click here to Skip to main content
13,046,474 members (71,112 online)
Rate this:
Please Sign up or sign in to vote.
Hi, I encountered a problem while trying to initialize two applications on my computer to communicate across the Windows peer-to-peer component. This is a continuation of my previous question: Windows P2P Native API[^] and might be actually related. The problem I describe in the linked question was "solved" by changing the default value of port during registration into PNRP:

ZeroMemory( ®Info, sizeof( PEER_PNRP_REGISTRATION_INFO ) );
regInfo.pwzCloudName = L"Global_";
regInfo.pwzComment = L"P2P Server";
regInfo.wPort = 2000;
regInfo.cAddresses = PEER_PNRP_AUTO_ADDRESSES;
if( SUCCEEDED( PeerPnrpRegister( peerName, ®Info, ® ) ) )

note the "regInfo.wPort = 2000;" line - if I don't do it, then the call to PeerGraphConnect fails as described in the former question. However, if I fill in some port number, the graph connection is at first successful and I am able to subscribe for events. However, the first event I receive is the PEER_GRAPH_EVENT_NEIGHBOR_CONNECTION with connection status set to PEER_CONNECTION_FAILED. Reason is usually PEER_E_CONNECTION_FAILED, unless I specify port 80 in the original peer registration. Then, the reason for failing is set to PEER_E_CONNECTION_NOT_AUTHENTICATED.

The MSDN page[^] is not very specific regarding this error, but I guess this is some general networking issue with my code. So my questions are as follows:
* Why does the registration not select a valid port by itself?
* And how do I select a valid port manually so that the second application is able to contact the registered peer?

Thanks for any input
Posted 30-Mar-13 1:23am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

please read to kickstart your knowledge:[^]
The_Inventor 15-Aug-13 0:27am
So many to choose from, If you use a known port and connect, do they see you?
KarstenK 15-Aug-13 2:25am
Are you too lazy to read the documentation?

At the end stands your solutuin: "The range 49152–65535 above the registered ports – contains dynamic or private ports that cannot be registered with IANA. This range is used for custom or temporary purposes and for automatic allocation of ephemeral ports."

use ports in that range :duh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100