static void TestClient(string ip, int port) { TCPClient client = new TCPClient(ip, port, new ClientListener()); client.ConnectToTCPServer(); Thread.Sleep(2000); while (true) { //client.SendMessage("Client msg."); Thread.Sleep(1000); } }
// Use this for initialization void Start() { if (ipInputField != null && ipInputField.text != "") { ipAddress = IPAddress.Parse(ipInputField.text); } else { ipAddress = IPAddress.Parse("127.0.0.1"); } //ipAddress = TCPEnd.GetFirstLocalIPAddressWithOpenTCPPort(SharedARServer.PORT); client = new TCPClient(ipAddress.ToString(), SharedARServer.PORT, this); client.ConnectToTCPServer(); }
static void TestServerAndClient() { string ip = "127.0.0.1"; int port = 4040; ServerListener listener = new ServerListener(ip, port); TCPServer server = new TCPServer(ip, port, listener); Thread.Sleep(2000); TCPClient client = new TCPClient(ip, port, new ClientListener()); client.ConnectToTCPServer(); Thread.Sleep(2000); while (true) { client.SendMessage("Client msg."); Thread.Sleep(1000); } }