I've opened a TCP port using upnplib libraries, and the port is actually opened, but when i try connecting to a SocketServer listening to that port, i get no response.
upnplib: [http://www.sbbi.net/site/upnp/index.html]
public Test() {
int port=54780;
int discoveryTimeout = 2000;
try {
//Discovery of the router
InternetGatewayDevice[] IGDs = InternetGatewayDevice.getDevices(discoveryTimeout);
if (IGDs != null) {
InternetGatewayDevice testIGD = IGDs[0]; //Internal Address
local=InetAddress.getLocalHost().getHostAddress(); //Open a new TCP port called UPnP Test
testIGD.addPortMapping("UPnP Test",null,port,port,local,0,"TCP");
}
} catch (Exception ex) {
ex.printStackTrace();
}
try {
System.out.println("listening on port:"+port);
server=new ServerSocket(port); //Server listening on opened port
while(true){
//Accept the client and create comunication streams
client=server.accept();
System.out.println("Client found:"+client.getInetAddress());
in=new BufferedReader(new InputStreamReader(client.getInputStream()));
out=new PrintStream(client.getOutputStream());
this.start(); //Listening method on a new Thread
}
}catch(IOException ex){
ex.printStackTrace();
}
}
Edited by: Cap_Snake8 on May 16, 2010 3:06 PM