예제 #1
0
        /// <summary>
        /// Connects to a node by using the given <see cref="EndPoint"/>.
        /// </summary>
        /// <param name="ep"><see cref="EndPoint"/> to use</param>
        public void StartConnect(EndPoint ep)
        {
            maxConnectionEnforcer.WaitOne();
            SocketAsyncEventArgs connectEventArgs = connectPool.Pop();

            connectEventArgs.RemoteEndPoint = ep;
            connectEventArgs.AcceptSocket   = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            StartConnect(connectEventArgs);
        }
예제 #2
0
        private void StartAccept()
        {
            SocketAsyncEventArgs acceptEventArg = acceptPool.Pop();

            maxConnectionEnforcer.WaitOne();
            if (!listenSocket.AcceptAsync(acceptEventArg))
            {
                ProcessAccept(acceptEventArg);
            }
        }