示例#1
0
        public static void PipeSockets(AsyncSocket socketA, AsyncSocket socketB)
        {
            socketA.Read(socketB.Write);
            socketB.Read(socketA.Write);

            socketA.Disconnect(socketB.Disconnect);
            socketB.Disconnect(socketA.Disconnect);
        }
示例#2
0
        public void TestServerDisconnect()
        {
            Until((port, done) =>
            {
                var server = new AsyncSocket();
                server.Listen(port, socket => socket.Disconnect());

                var client = new AsyncSocket();
                client.Disconnect(done);
                client.Connect(Host, port);
                client.Read(text => {});
            });
        }
示例#3
0
        public void TestClientPingDisconnect()
        {
            Until((port, done) =>
            {
                var server = new AsyncSocket();
                server.Listen(port, socket => socket.Read(text =>
                {
                    Assert.AreEqual("Hello, world!", text);
                    socket.Disconnect();
                }));

                var client = new AsyncSocket();
                client.Disconnect(done);
                client.Connect(Host, port, () => client.Write("Hello, world!"));
                client.Read(text => { });
            });
        }
示例#4
0
        public void TestServerToClientDisconnect()
        {
            Until((port, done) =>
            {
                var portTestServer = port;
                var portServer     = portTestServer + 1;

                var testServer = new AsyncSocket();
                var server     = new AsyncSocket();
                var client     = new AsyncSocket();
                var netro      = new Netro.Netro();

                server.Listen(portServer);
                netro.ServerToClient(server, Host, portTestServer);

                testServer.Listen(portTestServer, socket => socket.Disconnect());

                client.Connect(Host, portServer, () =>
                {
                    client.Read(text => { });
                    client.Disconnect(done);
                });
            });
        }