serveTCP

Create a new TCP based API server.

  1. TCPServer!(Implementation, API) serveTCP(ushort port)
  2. TCPServer!(Implementation, API) serveTCP(ushort port, string address)
    TCPServer!(Implementation, API)
    serveTCP
    (
    Implementation
    API
    )
    (
    ushort port
    ,
    string address
    )
    if (
    isServerAPI!(Implementation, TCPConnection)
    )

Examples

abstract static class API
{
    string someMethod(string name);
}

static class Implementation : API
{
    static Implementation startSession(TCPConnection conn)
    {
        return new Implementation();
    }

    override string someMethod(string name)
    {
        return "Hello " ~ name ~ "!";
    }
}

auto server = serveTCP!(Implementation, API)(8030);
server.stop();

Meta