Function EventLoop.createServer

A coroutine which creates a TCP server bound to host and port.

Prototype

Server createServer(
  Protocol delegate() protocolFactory,
  const(char[]) host = null,
  const(char[]) service = null,
  std.socket.AddressFamily addressFamily = UNSPECIFIED(),
  std.socket.AddressInfoFlags addressInfoFlags = cast(AddressInfoFlags)1,
  std.socket.Socket socket = null,
  int backlog = 100,
  asynchronous.events.SslContext sslContext = null,
  bool reuseAddress = true
);

Parameters

NameDescription
protocolFactory is a callable returning a protocol instance.
host if empty then all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6).
service service name or port number.
addressFamily can be set to either AddressFamily.INET or AddressFamily.INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AddressFamily.UNSPEC).
addressInfoFlags a bitmask for getAddressInfo().
socket can optionally be specified in order to use a preexisting socket object.
backlog the maximum number of queued connections passed to listen() (defaults to 100).
sslContext can be set to an SSLContext to enable SSL over the accepted connections.
reuseAddress tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to true on UNIX.

Returns

a Server object which can be used to stop the service.

Authors

Dragos Carp

Copyright

© 2015-2016 Dragos Carp

License

Boost Software License - Version 1.0