Communication between clients or peer-to-peer networking (“P2P communication” here in after) means the direct communication between client hosts without going through server. P2P communication becomes useful for the following cases.
In case the amount of data is simply too big to send it through server : If the data exceeds more than 10KB/sec and many clients are connected to the server, then the data piling in the server would be immersive. The communication line speed takes a huge part in the server maintenance cost. Thus it is much efficient and cost-saving to allow the clients exchange data by themselves without the help of server.
In case the physical distance between client and server is too far away: Let's say client A and B live in Brazil but the server is in Japan. When A wants to send a message to B then the data has to travel one circle around the globe for delivery. However, the direct P2P communication between A and B would allow the data travel for much shorter distance. This advantage becomes more useful when servicing the game globally.
In case lower latency is preferred: If client can send a message directly to another client without going through the server, the message would be delivered much faster. (Remark: This isn't always the case since it has a dependency over the internet structure and speed of your ISP.)
P2P communication of ProudNet provides strong hole-punching and P2P relay functionality which help developers developing their game with the feature already enabled and ready to be implemented.
P2P communication between clients in ProudNet is being handled by the unit of message. This means 1 message responds to 1 time call of RMI (Refer to 4. Remote Method Invocation)
Communication between clients in ProudNet is possible by both reliable and unreliable. (Refer to Protocol type of ProudNet)
to make P2P connection between clients, first the clients must P2P Group together in the server first. P2P communication only works between clients in the same P2P group.
When the server makes a P2P group of clients, the clients can communicate by P2P relay through the server. In the meantime, the server perform P2P hole-punching in the background and when it has done, the clients can communicate with each other without the help of server. Because of this particular feature, clients can send and receive a message from each other instantly in ProudNet as long as they form a P2P group. There could be a slight increase of data amount being transferred as soon as clients with in P2P group start communication. That is simply because the server is performing hole-punching between hosts at the time.
P2P communication between hole-punched clients can be handled by custom-made reliable UDP of ProudNet. But until hole-punching succeeds, it will be done by P2P relay through UDP or TCP.
UDP port used by client for P2P communication is same as the one used for connecting to server.