klyn.net.ServerSocket.ServerSocket
constructor
public ServerSocket(port as Int) throws IOException:
Description

Creates a listening TCP socket.

A port of 0 asks the operating system to select an available ephemeral port. The assigned value is then available through localPort.

import klyn.net

try server = ServerSocket(0):
print(server.localPort)
Parameters
ParameterDescription
portRequested TCP port, or 0 for an automatically assigned port.
Throws
  • IOException if the socket stream is closed, disconnected, times out, or the underlying network I/O fails.