For a file sharing application I would like to use TCP/IP Sockets. But this doesn’t work because both clients are behind NATs. Therefore I have to use UDP and the hole punching method.
Since UDP is not reliable, I have to implement a TCP-like protocol. I don’t need streams. A message based protocol would be ok. Is there already a free Java library somewhere? If not, is there an abstract tutorial, how to implement such a protocol?
You Can Implement TCP hole Punching that will allow two peer to communicate behind fire wall.
first go through this link
http://www.brynosaurus.com/pub/net/p2pnat/
and then update the question if need further help on this.But the problem with TCP hole punching is that it can be successful in 60% of router available in the market whereas UDP hole punching is 80-90% successful.
check out this link as well.http://stackoverflow.com/questions/917385/nat-traversal-with-java