我目前正在为一款名为 GTA 的游戏开发 Match Maker,问题是游戏服务器使用 7777 端口,我需要向世界开放此端口以允许玩家加入服务器,我不希望用户对其路由器进行任何更改。
注意:游戏服务器不是我的,我不能修改它的源代码,我只是启动它。
所以,我发现Cling可以处理端口转发,但我不能让它工作!
我正在使用的代码:
public static void openports() throws UnknownHostException {
InetAddress i = InetAddress.getLocalHost();
System.out.println(i.getHostAddress());
UpnpService upnpServiceTCP = new UpnpServiceImpl(new PortMappingListener(new PortMapping(7777, i.getHostAddress(), PortMapping.Protocol.TCP)));
upnpServiceTCP.getControlPoint().search(new STAllHeader());
UpnpService upnpServiceUDP = new UpnpServiceImpl(new PortMappingListener(new PortMapping(7777, i.getHostAddress(), PortMapping.Protocol.UDP)));
upnpServiceUDP.getControlPoint().search(new STAllHeader());
}
任何人都知道让它工作吗?