示例#1
0
        public Connection(TcpClient c, ServerHost s)
        {
            Client = c;
            Server = s;
            ClientStream = Client.GetStream();
            cancelToken = cTokenSource.Token;

            originIP = Client.Client.RemoteEndPoint.ToString();

            Client.LingerState = new LingerOption(false, 0);

            State = ClientState.CONNECTED;

            Server.Connections.Add(this);

            Helper.LogConsole("Connection", string.Format("New connection from {0}", originIP));
            Task.Run(WaitForData, cancelToken).ConfigureAwait(false);
            Task.Run(DoPostConnect);
        }
示例#2
0
        static void Main(string[] args)
        {
            ServerHost serv = new ServerHost(IPAddress.Parse("127.0.0.1"), 2142);

            serv.StartAnd().Wait();
        }