private void TestInternal(string host, int port) { var client = new TcpClientSocket(); client.Resolve(host, port.ToString(), (args1) => { if (!args1.Successful) { Console.WriteLine("failed to resolve host {0}", host); return; } Console.WriteLine("host resolved to {0}", args1.Data); client.Connect(args1.Data[0], (args2) => { if (!args2.Successful) { Console.WriteLine("connection failed"); return; } Console.WriteLine("connection to {0} successful", args1.Data); client.Close(false, (args3) => { if (!args3.Successful) { Console.WriteLine("failed to close connection"); return; } Console.WriteLine("connection closed"); }); }); }); }