Skip to main content

In which way can peers find each other?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
Mars2012
Offline
Joined: 2012-03-16

I am reading JXTA's Programmer's Guide and on page 63 I found an important sentence. The sentence is " In our example, we send Discovery Request messages to the local subnet and the rendezvous peers, looking for any peer".

I wonder for example how can a peer in London find a rendezvous in Berlin?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cuizhf
Offline
Joined: 2007-07-22

In my opinion, in your example if a peer in London want to find a rendezvous in Berlin, it must satisfy the following cinditions:

First of all, the peer in London must be able to connect to the peer in Berlin physically, this usually means that the peer in Berlin has a public IP address, then the two peers can communicate with each other on Internet.

second, you must set up some settings in your code:
1 In Berlin's peer running as a rendezvous, you start the peer with RENDEZVOUS' mode(NetworkManager.ConfigMode.RENDEZVOUS) and before you call NetworkManager.startNetwork(), you should also call some function like this:
NetworkConfigurator config = manager.getConfigurator();
config.setTcpPublicAddress("202.118.110.100:9701", true);
note, 202.118.110.100:9701 is public ip address(so London peer can access) and corresponding port number.
2 In London's peer usually running as an edge, before you call NetworkManager.startNetwork(),you should call some function like this:
NetworkConfigurator config = manager.getConfigurator();
config.addSeedRendezvous(URI.create("tcp://202.118.110.100:9701"));
then you should call PeerGroup.getRendezVousService().isConnectedToRendezVous(), so you can be sure that London's peer has connected to Berlin's peer.

That's all. My English is not very good but I think I have expressed my thought clearly.