Question

I had found code for peer-to-peer chat, but the thorny problems are :

1- Is there is automatic way for the srver and client to get the IP of each other (often dynamic IP) ?

N.B: I read this questions which use an intermediate server but I can't design my own server, so I am searching for another idea:

Creating Peer to Peer connections using intermediate server

Writing a simple P2P chat application

2- Can hackers use the port opened by the chat program ?

Was it helpful?

Solution

One way to locate another peer in a local area network is to broadcast a specifically constructed packet to the whole IPv4 subnet using the broadcast address. Then the peer client can be written to respond to the host who broadcasted the message and make a connection. A perfect example of an application that uses this method is Dropbox. Dropbox uses what they call LAN sync that allows for files to be transfered from peer to peer if that file is present in a dropbox on a host within the LAN. If you fire up wireshark, you can see the LAN sync messages being broadcasted from the broadcast address.

Hackers can use any remote communication protocol to exploit an application if there is a vulnerability present. The best way avoid this is by using secure coding practices and end-to-end encryption. It's not the ports necessarily being open or close that you need to worry about, but the code sitting at the application layer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top