Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

10
LINES

< > BotCompany Repo | #1000984 // makeServerSocket

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (13026L/74K).

1  
static ServerSocket makeServerSocket() ctex {
2  
  for (int port = 10000; port < 65535; port++) {
3  
    try {
4  
      return new ServerSocket(port);
5  
    } catch (IOException e) {
6  
      // try next port
7  
    }
8  
  }
9  
  throw fail("No free port found (tried 10000-65535)");
10  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000984
Snippet name: makeServerSocket
Eternal ID of this version: #1000984/1
Text MD5: 480f9bf58f908098dc46111ef69a0d47
Transpilation MD5: b7f55d7f6dcc07b98ef503119a19de57
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-07-15 23:34:22
Source code size: 271 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 721 / 1035
Referenced in: [show references]