예제 #1
0
        //  Internal function to start the actual connection establishment.
        private void StartConnecting()
        {
            //  Open the connecting socket.

            try
            {
                Open();

                //  Connect may succeed in synchronous manner.
                m_handle = m_s;
                m_ioObject.AddFd(m_handle);
                m_handleValid = true;
                m_ioObject.OutEvent();
            }
            catch (NetMQException ex)
            {
                if (ex.ErrorCode == ErrorCode.EINPROGRESS)
                {
                    //  Connection establishment may be delayed. Poll for its completion.
                    m_handle = m_s;
                    m_ioObject.AddFd(m_handle);
                    m_handleValid = true;
                    m_ioObject.SetPollout(m_handle);
                    m_socket.EventConnectDelayed(m_endpoint, ex.ErrorCode);
                }
                else
                {
                    //  Handle any other error condition by eventual reconnect.
                    if (m_s != null)
                    {
                        Close();
                    }
                    AddReconnectTimer();
                }
            }
        }