示例#1
0
 static async Task Main(string[] args)
 {
     var messageProtocol              = new LengthProtocol();
     DoSomethingWithEachClient sa     = new DoSomethingWithEachClient(messageProtocol);
     ReadWriteServer           server = new ReadWriteServer(sa);
     await server.StartAsync();
 }
示例#2
0
        public ReadWriteServer(DoSomethingWithEachClient serverApplication)
        {
            _serverApplication = serverApplication;

            _listenSocket = new Socket(SocketType.Stream, ProtocolType.Tcp);
            _listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, 8087));
            Console.WriteLine("Listening on port 8087");
            _listenSocket.Listen(120);
        }