net/serversocket.eh

Server sockets. More...

use "net/serversocket.eh"

Constants

const ANY_PORT = -1

Types

type ServerSocket < Connection;

Functions

def ServerSocket.accept(): Socket;
def ServerSocket.get_localhost(): String;
def ServerSocket.get_localport(): Int;
def ServerSocket.new(port: Int = ANY_PORT): ServerSocket;

Description

This header provides server sockets. A server socket waits for requests to come in over the network. It performs some operation based on that request, and then possibly returns a result to the requester.

Constant details

const ANY_PORT = -1
Specifies that connection port may be dynamically selected by platform.

Type details

type ServerSocket < Connection;
A server socket.

Function details

def ServerSocket.new(port: Int = ANY_PORT): ServerSocket;
Creates new server socket bound to the given port. The constant ANY_PORT may be used to indicate that connection port may be provided automatically by platform. In the latter case the port can be discovered by get_localport.

def ServerSocket.get_localhost(): String;
Returns the local host to which the socket is bound.

def ServerSocket.get_localport(): Int;
Returns the local port to which the socket is bound.

def ServerSocket.accept(): Socket;
Waits for incoming connection and then returns it.