开发者

TCP implementation in Java using UDP (Datagrams)

开发者 https://www.devze.com 2023-03-16 16:34 出处:网络
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.

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 b开发者_如何学JAVAased 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


If you search for a UDP-based message-oriented protocol, I'd consider TeleHash. There are also Java libraries available.

Maybe it's the wrong choice if you rely on high volumes of binary data to be transmitted, but then a stream-based protocol might be the better choice anyway.


was it helpful?

http://www.syslog4j.org/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号