Click here to Skip to main content
Rate this: bad
good
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:
 
PEER_PNRP_REGISTRATION_INFO regInfo;
ZeroMemory( &regInfo, sizeof( PEER_PNRP_REGISTRATION_INFO ) );
regInfo.pwzCloudName = L"Global_";
regInfo.pwzComment = L"P2P Server";
regInfo.wPort = 2000;
regInfo.cAddresses = PEER_PNRP_AUTO_ADDRESSES;
HREGISTRATION reg;
if( SUCCEEDED( PeerPnrpRegister( peerName, &regInfo, &reg ) ) )
{
}
 
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 2:23am

1 solution

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

Solution 1

please read to kickstart your knowledge: http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers[^]
  Permalink  
Comments
The_Inventor at 15-Aug-13 0:27am
   
So many to choose from, If you use a known port and connect, do they see you?
KarstenK at 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
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 204
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 183
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2014
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