Fork Copy int kt; byte[] dl = new byte[1024]; Socket sk = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint serverInfo = new IPEndPoint(IPAddress.Loopback, 9000); EndPoint Server = (EndPoint) serverInfo; Console.WriteLine("Connecting to server"); dl = getByte("Hello"); sk.SendTo(dl, dl.Length, SocketFlags.None, Server); dl = new byte[1024]; kt = sk.ReceiveFrom(dl, ref Server); Console.WriteLine(getString(dl, 0, kt)); while (true) { //nhap du lieu string input = Console.ReadLine(); if (input == "exit") { break; } dl = getByte(input); sk.SendTo(dl, dl.Length, SocketFlags.None, Server); dl = new byte[1024]; //nhan lai du lieu kt = sk.ReceiveFrom(dl, ref Server); string s = getString(dl, 0, kt); if (s.Length == 0) { break; } Console.WriteLine(s.Trim()); } sk.Close(); Console.WriteLine("Stopped"); Console.ReadLine(); public static void log(string a) { Console.WriteLine(a); }