我将使用 STUN 作为我的遍历 NAT 解决方案,并遇到 JSTUN。虽然我搜索了 arround stackoverflow,但我发现这篇文章提到 JSTUN 在源代码中有它的文档:Java 和我应该使用哪些 Stun 库?
但是,http://javawi.de/ 上的源代码已损坏,然后我找到了下载 JSTUN 代码的替代方法https://github.com/tking/JSTUN
所以我在这里询问是否有人会给我文件,并想知道它是如何工作的:
1.de.javawi.jstun.test.demo.StunServer 要求我提供 2 个 ip 和端口。在我看来,STUN 服务器是一种提供“打孔”服务的方式,为什么它需要 2 个 ip 和端口?
2.运行de.javawi.jstun.test.demo.DiscoveryTestDemo后,返回ip,是什么意思?
No route to host
java.io.IOException: No route to host
No route to host
at java.net.PlainDatagramSocketImpl.send(Native Method)
at java.net.DatagramSocket.send(DatagramSocket.java:625)
at de.javawi.jstun.test.DiscoveryTest.test1(DiscoveryTest.java:96)
at de.javawi.jstun.test.DiscoveryTest.test(DiscoveryTest.java:64)
at de.javawi.jstun.test.demo.DiscoveryTestDemo.run(DiscoveryTestDemo.java:48)
at java.lang.Thread.run(Thread.java:680)
java.io.IOException: No route to host
at java.net.PlainDatagramSocketImpl.send(Native Method)
at java.net.DatagramSocket.send(DatagramSocket.java:625)
at de.javawi.jstun.test.DiscoveryTest.test1(DiscoveryTest.java:96)
at de.javawi.jstun.test.DiscoveryTest.test(DiscoveryTest.java:64)
at de.javawi.jstun.test.demo.DiscoveryTestDemo.run(DiscoveryTestDemo.java:48)
at java.lang.Thread.run(Thread.java:680)
Network interface: en0
Local IP address: 192.168.1.23
Result: Port restricted Cone NAT handles connections.
Public IP address: 116.48.14.100
问候,
史蒂夫