Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net.Sockets;
- using System.Net;
- using System.Text;
- class Program
- {
- static void Main(string[] args)
- {
- string message;
- byte[] bytes = new byte[1024];
- Console.WriteLine("Для завершения работы клиента пропишите end");
- IPHostEntry ipHost = Dns.GetHostEntry("localhost");
- IPAddress ipAddr = ipHost.AddressList[1];
- IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 11320);
- Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- sender.Connect(ipEndPoint);
- while (true)
- {
- message = Console.ReadLine();
- int bytesSend = sender.Send(Encoding.UTF8.GetBytes(message));
- if (message == "end") { break; }
- }
- sender.Shutdown(SocketShutdown.Both);
- sender.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment