public static void PipeSockets(AsyncSocket socketA, AsyncSocket socketB) { socketA.Read(socketB.Write); socketB.Read(socketA.Write); socketA.Disconnect(socketB.Disconnect); socketB.Disconnect(socketA.Disconnect); }
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 => {}); }); }
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 => { }); }); }
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); }); }); }