private void EnableInterest(SocketChannel channel, SocketAsyncOperation op) { switch (op) { case SocketAsyncOperation.Accept: case SocketAsyncOperation.Receive: Execute(() => { _read.Add(channel.Socket, channel); if (_read.Count == 1 && _write.Count == 0) // Start the select loop on initial enable interest { Select(); // The select loop will stop itself if no more interested sockets } }); break; case SocketAsyncOperation.Connect: case SocketAsyncOperation.Send: Execute(() => { _write.Add(channel.Socket, channel); // Start the select loop on initial enable interest if (_read.Count == 0 && _write.Count == 1) // The select loop will stop itself if no more interested sockets { Select(); } }); break; } }
protected TcpConnection(TcpExt tcp, SocketChannel channel, bool pullMode) { _tcp = tcp; _channel = channel; _pullMode = pullMode; _readingSuspended = pullMode; }
public void Register(SocketChannel channel, SocketAsyncOperation?initialOps, IActorRef channelActor) { channel.Register(channelActor, initialOps); if (initialOps.HasValue) { EnableInterest(channel, initialOps.Value); } channelActor.Tell(new ChannelRegistration( enableInterest: op => EnableInterest(channel, op), disableInterest: op => DisableInterest(channel, op) )); }
public TcpIncomingConnection(TcpExt tcp, SocketChannel channel, IChannelRegistry registry, IActorRef bindHandler, IEnumerable <Inet.SocketOption> options, bool readThrottling) : base(tcp, channel, readThrottling) { _bindHandler = bindHandler; _options = options; Context.Watch(bindHandler); // sign death pact registry.Register(channel, SocketAsyncOperation.None, Self); }
public TcpIncomingConnection(TcpExt tcp, SocketChannel channel, IChannelRegistry registry, IActorRef bindHandler, IEnumerable<Inet.SocketOption> options, bool readThrottling) : base(tcp, channel, readThrottling) { _bindHandler = bindHandler; _options = options; Context.Watch(bindHandler); // sign death pact registry.Register(channel, SocketAsyncOperation.None, Self); }
private void DisableInterest(SocketChannel channel, SocketAsyncOperation op) { switch (op) { case SocketAsyncOperation.Accept: case SocketAsyncOperation.Receive: Execute(() => _read.Remove(channel.Socket)); break; case SocketAsyncOperation.Connect: case SocketAsyncOperation.Send: Execute(() => _write.Remove(channel.Socket)); break; } }
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 } }
/// <summary> /// TBD /// </summary> /// <param name="channel">TBD</param> public FailedRegisterIncoming(SocketChannel channel) { Channel = channel; }
public FailedRegisterIncoming(SocketChannel channel) { Channel = channel; }
internal SocketChannel AcceptServerSideChannel(SocketChannel localServer) { var promise = new TaskCompletionSource<Socket>(); var task = promise.Task; localServer.Socket.Listen(100); localServer.Socket.BeginAccept(ar => promise.SetResult(localServer.Socket.EndAccept(ar)), null); Selector.Send(ConnectionActor, SelectionHandler.ChannelConnectable.Instance); task.Wait(); var channel = new SocketChannel(task.Result); channel.Register(ChannelProbe, SocketAsyncOperation.None); return channel; }
public Registration(SocketChannel channel, SocketAsyncOperation? initialOps) { Channel = channel; InitialOps = initialOps; }
public void Register(SocketChannel channel, SocketAsyncOperation? initialOps, IActorRef channelActor) { channel.Register(channelActor, initialOps); RegisterCallReceiver.Ref.Tell(new TcpConnectionSpec.Registration(channel, initialOps)); }
public void AbortClose(SocketChannel channel) { // TODO: Do we need to handle expection like JVM? channel.Socket.LingerState = new LingerOption(true, 0); channel.Close(); }
public void Register(SocketChannel channel, SocketAsyncOperation? initialOps, IActorRef channelActor) { _test._registerCallReceiver.Ref.Tell(initialOps, channelActor); }