public TcpOutgoingConnection(TcpExt tcp, IChannelRegistry channelRegistry, IActorRef commander, Tcp.Connect connect)
: base(tcp, SocketChannel.Open().ConfigureBlocking(false), connect.PullMode)
{
_channelRegistry = channelRegistry;
_commander = commander;
_connect = connect;
Context.Watch(commander); // sign death pact
connect.Options.ForEach(_ => _.BeforeConnect(Channel.Socket));
if (connect.LocalAddress != null)
{
Channel.Socket.Bind(connect.LocalAddress);
}
channelRegistry.Register(Channel, SocketAsyncOperation.None, Self);
if (connect.Timeout.HasValue)
{
Context.SetReceiveTimeout(connect.Timeout.Value); //Initiate connection timeout if supplied
}
}