Preparing search index...

    Base class for network servers, providing common listen and connection management functionality.

        // BaseServer is the base class for network servers. Use TcpServer as a
    // concrete subclass to demonstrate listen(), close(), onConnect, onError.
    const server = TcpServer.create();
    this.server = server;

    this.connections.push(
    server.onConnect.connect((socket) => {
    console.log('Client connected from:', socket.remoteAddress.address);
    })
    );
    this.connections.push(
    server.onError.connect((code: number) => {
    console.log('Server error code:', code);
    })
    );

    const addr = new Address();
    addr.address = '127.0.0.1';
    addr.port = 0;
    const ok = server.listen(addr);
    console.log('Server listening:', ok, 'on port:', server.port);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    address: string

    The address string the server is currently bound to.

    onConnect: signal1<BaseSocket, void>

    Signal fired when a new client socket connects to the server.

    onError: signal1<number, void>

    Signal fired when a server error occurs, passing an error code.

    port: number

    Methods

    • Closes the server and stops accepting new connections.

      Returns void

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean

    • Starts listening for incoming connections on the specified address; returns true if successful.

      Parameters

      Returns boolean