void Complete(SocketAsyncEventArgs e, bool completeSynchronously) { TransportBase transport = null; Exception exception = null; if (e.SocketError != SocketError.Success) { exception = new SocketException((int)e.SocketError); if (e.AcceptSocket != null) { e.AcceptSocket.Close(0); } } else { Fx.Assert(e.AcceptSocket != null, "Must have a valid socket accepted."); transport = new TcpTransport(e.AcceptSocket, this.transportSettings); transport.Open(); } e.Dispose(); this.callbackArgs.CompletedSynchronously = completeSynchronously; this.callbackArgs.Exception = exception; this.callbackArgs.Transport = transport; if (!completeSynchronously) { this.callbackArgs.CompletedCallback(this.callbackArgs); } }
void Complete(SocketAsyncEventArgs e, bool completeSynchronously) { TransportBase transport = null; Exception exception = null; if (e.SocketError != SocketError.Success) { exception = new SocketException((int)e.SocketError); if (e.AcceptSocket != null) { e.AcceptSocket.Close(0); } } else { Fx.Assert(e.AcceptSocket != null, "Must have a valid socket accepted."); transport = new TcpTransport(e.AcceptSocket, this.transportSettings); transport.Open(); } e.Dispose(); this.callbackArgs.CompletedSynchronously = completeSynchronously; this.callbackArgs.Exception = exception; this.callbackArgs.Transport = transport; if (!completeSynchronously) { this.callbackArgs.CompletedCallback(this.callbackArgs); } }
private void Complete(SocketAsyncEventArgs e, bool completeSynchronously) { TransportBase tcpTransport = null; Exception socketException = null; if (e.SocketError == SocketError.Success) { try { e.ConnectSocket.NoDelay = true; tcpTransport = new TcpTransport(e.ConnectSocket, this.transportSettings); tcpTransport.Open(); } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } socketException = exception; if (tcpTransport != null) { tcpTransport.SafeClose(); } tcpTransport = null; } } else { socketException = new SocketException((int)e.SocketError); if (e.AcceptSocket != null) { e.AcceptSocket.Close(0); } } e.Dispose(); this.callbackArgs.CompletedSynchronously = completeSynchronously; this.callbackArgs.Exception = socketException; this.callbackArgs.Transport = tcpTransport; if (!completeSynchronously) { this.callbackArgs.CompletedCallback(this.callbackArgs); } }
bool HandleAcceptComplete(SocketAsyncEventArgs e, bool completedSynchronously) { if (e.SocketError == SocketError.Success) { TcpTransport transport = new TcpTransport(e.AcceptSocket, this.transportSettings); transport.Open(); TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs(); args.Transport = transport; args.CompletedSynchronously = completedSynchronously; this.OnTransportAccepted(args); return(true); } else { e.Dispose(); this.TryClose(new SocketException((int)e.SocketError)); return(false); } }
private bool HandleAcceptComplete(SocketAsyncEventArgs e, bool completedSynchronously) { if (e.SocketError == SocketError.Success) { TcpTransport tcpTransport = new TcpTransport(e.AcceptSocket, this.transportSettings); tcpTransport.Open(); TransportAsyncCallbackArgs transportAsyncCallbackArg = new TransportAsyncCallbackArgs() { Transport = tcpTransport, CompletedSynchronously = completedSynchronously }; base.OnTransportAccepted(transportAsyncCallbackArg); return(true); } bool flag = this.ShouldRetryAccept(e.SocketError); if (!flag) { e.Dispose(); base.SafeClose(new SocketException((int)e.SocketError)); } return(flag); }
bool HandleAcceptComplete(SocketAsyncEventArgs e, bool completedSynchronously) { if (e.SocketError == SocketError.Success) { TcpTransport transport = new TcpTransport(e.AcceptSocket, this.transportSettings); transport.Open(); TransportAsyncCallbackArgs args = new TransportAsyncCallbackArgs(); args.Transport = transport; args.CompletedSynchronously = completedSynchronously; this.OnTransportAccepted(args); return true; } else { e.Dispose(); this.TryClose(new SocketException((int)e.SocketError)); return false; } }