Function EventLoop.createConnection

Create a streaming transport connection to a given Internet host and

Prototype

auto std.typecons.__T5TupleTC12asynchronous10transports9TransportVAyaa9_7472616e73706f7274TC12asynchronous9protocols8ProtocolVAyaa8_70726f746f636f6cZ.Tuple createConnection(
  Protocol delegate() protocolFactory,
  const(char[]) host = null,
  const(char[]) service = null,
  asynchronous.events.SslContext sslContext = null,
  std.socket.AddressFamily addressFamily = UNSPECIFIED(),
  std.socket.ProtocolType protocolType = UNSPECIFIED(),
  std.socket.AddressInfoFlags addressInfoFlags = UNSPECIFIED(),
  std.socket.Socket socket = null,
  const(char[]) localHost = null,
  const(char[]) localService = null,
  const(char[]) serverHostname = null
);

port

socket family AddressFamily.INET or AddressFamily.INET6 depending on host (or family if specified), socket type SocketType.STREAM.

This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) tuple.

The chronological synopsis of the underlying operation is as follows:

The connection is established, and a transport is created to represent it. protocolFactory is called without arguments and must return a protocol instance. The protocol instance is tied to the transport, and its connectionMade() method is called. The coroutine returns successfully with the (transport, protocol) tuple.

The created transport is an implementation-dependent bidirectional stream.

Options allowing to change how the connection is created:

Parameters

NameDescription
protocolFactory is a callable returning a protocol instance
host if empty then the socket parameter should be specified.
service service name or port number.
sslContext if not null, a SSL/TLS transport is created (by default a plain TCP transport is created).
serverHostname is only for use together with ssl, and sets or overrides the hostname that the target server’s certificate will be matched against. By default the value of the host argument is used. If host is empty, there is no default and you must pass a value for serverHostname. If serverHostname is empty, hostname matching is disabled (which is a serious security risk, allowing for man-in-the-middle-attacks).
addressFamily optional adress family.
protocolType optional protocol.
addressInfoFlags optional flags.
socket if not null, should be an existing, already connected Socket object to be used by the transport. If socket is given, none of host, service, addressFamily, protocolType, addressInfoFlags and localAddress should be specified.
localHost if given, together with localService is used to bind the socket locally. The localHost and localService are looked up using getAddressInfo(), similarly to host and service.
localService see localHost.

Returns

Tuple!(Transport, "transport", Protocol, "protocol")

Authors

Dragos Carp

Copyright

© 2015-2016 Dragos Carp

License

Boost Software License - Version 1.0