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( ®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