public TcpConnecter(IOThread ioThread, SessionBase session, Options options, Address addr, bool delayedStart) : base(ioThread, options) { m_ioObject = new IOObject(ioThread); m_addr = addr; m_handle = null; m_handleValid = false; m_delayedStart = delayedStart; m_timerStarted = false; m_session = session; m_currentReconnectIvl = m_options.ReconnectIvl; Debug.Assert(m_addr != null); m_endpoint = m_addr.ToString(); m_socket = session.Socket; }
private void Unplug() { Debug.Assert(m_plugged); m_plugged = false; // Cancel all fd subscriptions. if (!m_inputError) m_ioObject.RmFd(m_handle); // Disconnect from I/O threads poller object. m_ioObject.Unplug(); // Disconnect from session object. if (m_encoder != null) m_encoder.SetMsgSource(null); if (m_decoder != null) m_decoder.SetMsgSink(null); m_session = null; }
public StreamEngine(Socket fd, Options options, String endpoint) { m_handle = fd; // inbuf = null; m_insize = 0; m_inputError = false; // outbuf = null; m_outsize = 0; m_handshaking = true; m_session = null; m_options = options; m_plugged = false; m_endpoint = endpoint; m_socket = null; m_encoder = null; m_decoder = null; // Put the socket into non-blocking mode. Utils.UnblockSocket(m_handle); // Set the socket buffer limits for the underlying socket. if (m_options.SendBuffer != 0) { m_handle.SendBufferSize = m_options.SendBuffer; } if (m_options.ReceiveBuffer != 0) { m_handle.ReceiveBufferSize = m_options.ReceiveBuffer; } }
public void Plug(IOThread ioThread, SessionBase session) { Debug.Assert(!m_plugged); m_plugged = true; // Connect to session object. Debug.Assert(m_session == null); Debug.Assert(session != null); m_session = session; m_socket = m_session.Socket; m_ioObject = new IOObject(null); m_ioObject.SetHandler(this); // Connect to I/O threads poller object. m_ioObject.Plug(ioThread); m_ioObject.AddFd(m_handle); // Send the 'length' and 'flags' fields of the identity message. // The 'length' field is encoded in the long format. m_greetingOutputBuffer[m_outsize++] = ((byte) 0xff); m_greetingOutputBuffer.PutLong((long) m_options.IdentitySize + 1, 1); m_outsize += 8; m_greetingOutputBuffer[m_outsize++] = ((byte) 0x7f); m_outpos = new ByteArraySegment(m_greetingOutputBuffer); m_ioObject.SetPollin(m_handle); m_ioObject.SetPollout(m_handle); // Flush all the data that may have been already received downstream. InEvent(); }