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
  • SocketException if the operating system cannot create a TCP socket.
  • IOException if binding or listening fails.