public void OutEvent() { // connected but attaching to stream engine is not completed. do nothing Socket fd = Connect(); m_ioObject.RmFd(m_handle); m_handleValid = false; if (fd == null) { // Handle the error condition by attempt to reconnect. Close(); AddReconnectTimer(); return; } Utils.TuneTcpSocket(fd); Utils.TuneTcpKeepalives(fd, m_options.TcpKeepalive, m_options.TcpKeepaliveCnt, m_options.TcpKeepaliveIdle, m_options.TcpKeepaliveIntvl); // Create the engine object for this connection. StreamEngine engine = new StreamEngine(fd, m_options, m_endpoint); // Attach the engine to the corresponding session object. SendAttach(m_session, engine); // Shut the connecter down. Terminate(); m_socket.EventConnected(m_endpoint, fd); }
public void InEvent() { Socket fd; try { fd = Accept(); Utils.TuneTcpSocket(fd); Utils.TuneTcpKeepalives(fd, m_options.TcpKeepalive, m_options.TcpKeepaliveCnt, m_options.TcpKeepaliveIdle, m_options.TcpKeepaliveIntvl); } catch (NetMQException ex) { // If connection was reset by the peer in the meantime, just ignore it. // TODO: Handle specific errors like ENFILE/EMFILE etc. //ZError.exc (e); m_socket.EventAcceptFailed(m_endpoint, ex.ErrorCode); return; } // Create the engine object for this connection. StreamEngine engine; try { engine = new StreamEngine(fd, m_options, m_endpoint); } catch (SocketException ex) { //LOG.error("Failed to initialize StreamEngine", e.getCause()); ErrorCode errorCode = ErrorHelper.SocketErrorToErrorCode(ex.SocketErrorCode); m_socket.EventAcceptFailed(m_endpoint, errorCode); throw NetMQException.Create(errorCode); } // Choose I/O thread to run connecter in. Given that we are already // running in an I/O thread, there must be at least one available. IOThread ioThread = ChooseIOThread(m_options.Affinity); // Create and launch a session object. SessionBase session = SessionBase.Create(ioThread, false, m_socket, m_options, new Address(m_handle.LocalEndPoint)); session.IncSeqnum(); LaunchChild(session); SendAttach(session, engine, false); m_socket.EventAccepted(m_endpoint, fd); }
public void OutEvent() { // connected but attaching to stream engine is not completed. do nothing Socket fd = Connect(); if (fd == null) { // Handle the error condition by attempt to reconnect. Close(); AddReconnectTimer(); return; } m_ioObject.RmFd(m_handle); m_handleValid = false; m_handle = null; Utils.TuneTcpSocket(fd); Utils.TuneTcpKeepalives(fd, m_options.TcpKeepalive, m_options.TcpKeepaliveCnt, m_options.TcpKeepaliveIdle, m_options.TcpKeepaliveIntvl); // Create the engine object for this connection. StreamEngine engine = new StreamEngine(fd, m_options, m_endpoint); // Attach the engine to the corresponding session object. SendAttach(m_session, engine); // Shut the connecter down. Terminate(); m_socket.EventConnected(m_endpoint, fd); }
public void OutEvent() { // connected but attaching to stream engine is not completed. do nothing bool err = false; Socket fd = null; try { fd = Connect(); } //catch (ConnectException e) { // err = true; //} catch (SocketException) { err = true; } //catch (IOException e) { // throw new ZError.IOException(e); //} m_ioObject.RmFd(m_handle); m_handleValid = false; if (err) { // Handle the error condition by attempt to reconnect. Close(); AddReconnectTimer(); return; } m_handle = null; try { Utils.TuneTcpSocket(fd); Utils.TuneTcpKeepalives(fd, m_options.TcpKeepalive, m_options.TcpKeepaliveCnt, m_options.TcpKeepaliveIdle, m_options.TcpKeepaliveIntvl); } catch (SocketException) { throw new Exception(); } // Create the engine object for this connection. StreamEngine engine; try { engine = new StreamEngine(fd, m_options, m_endpoint); } catch (SocketException) { //LOG.error("Failed to initialize StreamEngine", e.getCause()); m_socket.EventConnectDelayed(m_endpoint, ZError.ErrorNumber); return; } //alloc_Debug.Assert(engine); // Attach the engine to the corresponding session object. SendAttach(m_session, engine); // Shut the connecter down. Terminate(); m_socket.EventConnected(m_endpoint, fd); }