Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Net;
- using System.Net.Sockets;
- namespace Bus
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (true)
- {
- Console.WriteLine("Введите начало и конец пути через пробел: ");
- string message = Console.ReadLine();
- IPEndPoint ip = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8048);
- Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- try
- {
- sock.Connect(ip);
- sock.Send(Encoding.Unicode.GetBytes(message));
- Console.WriteLine("Начало и конец пути отправленнв на сервер ");
- int bytes = 0;
- byte[] buff = new byte[256];
- do
- {
- bytes = sock.Receive(buff);
- message = Encoding.Unicode.GetString(buff, 0, bytes);
- } while (sock.Available > 0);
- if (message[0] == '1')
- {
- Console.WriteLine(message);
- sock.Send(Encoding.Unicode.GetBytes("1"));
- Console.WriteLine("Подтверждение отправленно");
- }
- }
- catch(Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement