The solution I found is to assign a random identifying number to each peer and attach the identifier to the handshake message as well as registering the identifier with the P2P server. The other solution would be assigning random listening port to the peers so each peer listens on a random port and the probability of two peers with a same port number in a LAN is so low.