serversocket: Network server

This module supports creating TCP servers that listen on a specified port and accept incoming connections.

See also: The socket module allows creating TCP clients.

Class ServerSocket

class ServerSocket(port as Int[, address as Str])
Construct a TCP/IP server socket listening on the specified port of the local host. If the address argument is omitted or is nil, the server socket will listen to all the network interfaces. Otherwise, only the specified IP address will be listened to. The address must be of the form "123.45.67.89" (in decimal).

ServerSocket methods

accept([buffering as Constant])
Wait for an incoming connection. Return a socket::Socket object that represents the new connection.

The buffering parameter specifies the buffering mode of the socket. If omitted, the connection is unbuffered. Valid values for the parameter are io::Buffered, io::LineBuffered and io::Unbuffered.

close()
Close the socket. Free any resources allocated to the socket.