public void Run(Action <EstablishedConnectionTest> body) { Run((UnacceptedConnectionTest x) => { try { ServerSideChannel.Socket.Blocking = false; // JVM Akka always excpect CONNECT, which seems incorrect // We will not receive a CONNECT if Socket.BeginConnect completed synchronously // We therfore just igenore the CONNECT if it is in the queue //What JVM Akka does: InterestCallReceiver.ExpectMsg((int)SocketAsyncOperation.Connect); if (InterestCallReceiver.ReceiveWhile <object>(m => m is int && (int)m == (int)SocketAsyncOperation.Connect, TimeSpan.Zero, TimeSpan.Zero, 1).Any()) { Selector.Send(ConnectionActor, SelectionHandler.ChannelConnectable.Instance); // Only send ChannelConnectable if we did not complete synchronously } UserHandler.ExpectMsg <Tcp.Connected>(message => ((IPEndPoint)message.RemoteAddress).Port.ShouldBe(ServerAddress.Port)); //TODO: compare full endpoint, not only port UserHandler.Send(ConnectionActor, new Tcp.Register(ConnectionHandler.Ref, KeepOpenOnPeerClosed, UseResumeWriting)); if (!PullMode) { InterestCallReceiver.ExpectMsg((int)SocketAsyncOperation.Receive); } body(this); } finally { ServerSideChannel.Close(); } }); }
public void CloseServerSideAndWaitForClientReadable(bool fullClose = true) { if (fullClose) { ServerSideChannel.Close(); } else { ServerSideChannel.Socket.Shutdown(SocketShutdown.Send); } Thread.Sleep(200); }