示例#1
0
        /// <summary>
        /// Create a new acceptor using the connection info supplied by parameter.
        /// Start a new thread to process new connections
        /// </summary>
        /// <param name="listenerInfo">information for the connection, including address and port</param>
        /// <returns> the created acceptor </returns>
        public TCPMessageChannelAcceptor StartNewListener(ConnectionInfo listenerInfo)
        {
            TCPMessageChannelAcceptor channelAcceptor = null;

            lock (this)
            {
                try
                {
                    channelAcceptor = new TCPMessageChannelAcceptor(listenerInfo);

                    if (channelAcceptor == null)
                    {
                        return(null);
                    }

                    channelAcceptorList.Add(channelAcceptor);
                    DoBeginAcceptSocket(channelAcceptor);

                    if (log.IsDebugEnabled)
                    {
                        log.Debug("Created acceptor running in port " + channelAcceptor.LocalEndPoint);
                    }
                }
                catch (SocketException e)
                {
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("Can't open socket running in port :" + e.Message);
                    }
                    //maybe it is in use. Just Return.
                    return(null);
                }
                catch (Exception e)
                {
                    throw e;
                }
                return(channelAcceptor);
            }
        }
示例#2
0
        /// <summary>
        /// Create a new acceptor using the connection info supplied by parameter.
        /// Start a new thread to process new connections
        /// </summary>
        /// <param name="listenerInfo">information for the connection, including address and port</param>
        /// <returns> the created acceptor </returns>
        public TCPMessageChannelAcceptor StartNewListener(ConnectionInfo listenerInfo)
        {
            TCPMessageChannelAcceptor channelAcceptor = null;

            lock (this)
            {
                try
                {
                    channelAcceptor = new TCPMessageChannelAcceptor(listenerInfo);

                    if (channelAcceptor == null)
                    {
                        return null;
                    }

                    channelAcceptorList.Add(channelAcceptor);
                    DoBeginAcceptSocket(channelAcceptor);

                    if (log.IsDebugEnabled)
                        log.Debug("Created acceptor running in port " + channelAcceptor.LocalEndPoint);
                }
                catch (SocketException e)
                {
                    if (log.IsWarnEnabled)
                        log.Warn("Can't open socket running in port :" + e.Message);
                    //maybe it is in use. Just Return.
                    return null;
                }
                catch (Exception e)
                {
                    throw e;
                }
                return channelAcceptor;
            }
        }