コード例 #1
0
        /// <summary>
        /// 接收连接
        /// </summary>
        /// <param name="async"></param>
        private void OnBeginAcceptSocket(IAsyncResult async)
        {
            TcpListener listener = async.AsyncState as TcpListener;

            try
            {
                Socket client = listener.EndAcceptSocket(async);
                this.WriteLineLog(string.Format("于{0}接收到{1}的连接请求...---------------162", DateTime.Now.ToShortDateString(), client.RemoteEndPoint));
                TCPSocks5Connection.DoRequest(this, client);
                if (this.IsStarting)
                {
                    listener.BeginAcceptSocket(this.OnBeginAcceptSocket, this._Listener);
                }
            }
            catch (Exception ex)
            {
                this.WriteLineLog(string.Format("于{0}发生错误,错误信息:{1}---------------174", DateTime.Now, ex.Message));
            }
        }
コード例 #2
0
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="server"></param>
        /// <param name="client"></param>
        public static void DoRequest(TCPSocks5Server server, Socket client)
        {
            TCPSocks5Connection connection = new TCPSocks5Connection(server, client);

            ThreadPool.QueueUserWorkItem(new WaitCallback(connection.DoRequest));
        }