| 24 | } |
| 25 | |
| 26 | unsigned short AllocatePort(Socket& sock){ |
| 27 | unsigned short port = EPHEMERAL_PORT_RANGE_START; |
| 28 | |
| 29 | while(port <= EPHEMERAL_PORT_RANGE_END && AcquirePort(sock, port)) port++; |
| 30 | |
| 31 | if(port > EPHEMERAL_PORT_RANGE_END){ |
| 32 | Log::Warning("[Network] Could not allocate ephemeral port!"); |
| 33 | return 0; |
| 34 | } |
| 35 | |
| 36 | return port; |
| 37 | } |
| 38 | |
| 39 | int AcquirePort(Socket& sock, unsigned int port){ |
| 40 | if(port > PORT_MAX){ |
no test coverage detected