Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
4.00/5 (1 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:

C++
PEER_PNRP_REGISTRATION_INFO regInfo;
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;
HREGISTRATION reg;
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

1 solution

please read to kickstart your knowledge: http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers[^]
 
Share this answer
 
Comments
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


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900