Exemple #1
0
        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);
        }