예제 #1
0
        /// <summary>
        /// Send the Attach command
        /// </summary>
        /// <param name="destination">the Own to send the command to</param>
        /// <param name="engine"></param>
        /// <param name="incSeqnum"></param>
        protected void SendAttach([NotNull] SessionBase destination, [NotNull] IEngine engine, bool incSeqnum = true)
        {
            if (incSeqnum)
            {
                destination.IncSeqnum();
            }

            SendCommand(new Command(destination, CommandType.Attach, engine));
        }
예제 #2
0
        protected void SendAttach(SessionBase destination, IEngine engine, bool incSeqnum = true)
        {
            if (incSeqnum)
            {
                destination.IncSeqnum();
            }

            Command cmd = new Command(destination, CommandType.Attach, engine);

            SendCommand(cmd);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public void InEvent()
        {
            Socket fd;

            try
            {
                fd = Accept();
            }
            catch (SocketException ex)
            {
                m_socket.EventAcceptFailed(m_address.ToString(), ErrorHelper.SocketErrorToErrorCode(ex.SocketErrorCode));
                return;
            }
            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_address.ToString(), ex.ErrorCode);
                return;
            }

            PgmSocket pgmSocket = new PgmSocket(m_options, PgmSocketType.Receiver, m_address);

            pgmSocket.Init(fd);

            PgmSession pgmSession = new PgmSession(pgmSocket, m_options);

            IOThread ioThread = ChooseIOThread(m_options.Affinity);

            SessionBase session = SessionBase.Create(ioThread, false, m_socket,
                                                     m_options, new Address(m_handle.LocalEndPoint));

            session.IncSeqnum();
            LaunchChild(session);
            SendAttach(session, pgmSession, false);
            m_socket.EventAccepted(m_address.ToString(), fd);
        }
예제 #5
0
        protected void SendAttach(SessionBase destination,
		                            IEngine engine, bool incSeqnum)
        {
            if (incSeqnum)
                destination.IncSeqnum ();

            Command cmd = new Command(destination, CommandType.Attach, engine);
            SendCommand (cmd);
        }