如何在java中自动转发? [英] How to port forward automatically in java?
本文介绍了如何在java中自动转发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道bit torrent客户端使用自动端口转发(必须配置路由器的端口转发),以便它们可以相互连接。我希望我的应用程序中的用户能够托管服务器,而无需配置路由器。所以我想知道你将如何在java中这样做?
I know that bit torrent clients use automatic port forwarding (Port forwarding with having to configure the router) so that they can connect to each other. I want the users in my application to be able to host a server without having to configure the router. So I was wondering how you would do so in java?
推荐答案
你可以使用UPnP(通用即插即用)端口转发。提到的一个图书馆是 Cling ,但有更简单的图书馆 - WaifUPnP ,它允许您转发只有一行的端口,如:
You can use UPnP (Universal Plug and Play) port forwarding. One library mentioned is Cling, but there's much simpler library - WaifUPnP, which allows you to forward a port with just one line like:
UPnP.openTCP(portnumber);
这篇关于如何在java中自动转发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文