Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

Port(7777) has been used sometime weird when use s5b to transfer file.

$
0
0

Port 7777 has been used sometime weird, means that I have two phones, one can open port 7777, another one can't. The reason is that maybe a third app installed on the phone is using the port(7777).

 

I have seen the snippet which coms from org.jivesoftware.smackx.bytestreams.socks5.Socks5Proxy.

if (getLocalSocks5ProxyPort() < 0) {     int port = Math.abs(getLocalSocks5ProxyPort());     for (int i = 0; i < 65535 - port; i++) {          try{               this.serverSocket = new ServerSocket(port + i);               break;          }          catch (IOException e) {               // port is used, try next one           }     }}else{     this.serverSocket = new ServerSocket(getLocalSocks5ProxyPort());}

these codes are from publicsynchronizedvoidstart() method. Found that it just to check if port has been using when localSocks5ProxyPort < 0,

when not, doesn't check weather port is already in use or not.

 

I changed the snippet to what it is below:

int port = Math.abs(getLocalSocks5ProxyPort());try{      this.serverSocket = new ServerSocket(port);}catch (IOException e) {     for (int i = 0; i < 65535 - port; i++) {          try{               this.serverSocket = new ServerSocket(port + i);               break;           }           catch (IOException e1) {                // port is used, try next one           }     }} if (this.serverSocket != null) {     this.serverThread = new Thread(this.serverProcess);     this.serverThread.start();}else{     LOGGER.log(Level.SEVERE, "couldn't setup local SOCKS5 proxy through all ports.");}

And then everything is ok, the next port will be found if current one is already in use.

 

Anyone has better idea for this will be appreciated!


Viewing all articles
Browse latest Browse all 10742

Trending Articles