Advertisement
Guest User

Untitled

a guest
May 27th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1.        public void sendMessage(byte[] command,int id)
  2.         {
  3.             Socket s = ClientsControl.ClientList[id]._socket;
  4.             s.Send(command);
  5.             Console.WriteLine("Sent: " + command + " to " + s.RemoteEndPoint);
  6.         }
  7.  
  8.         public void prepareSend(EndPoint clientIp)
  9.         {
  10.             s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  11.             remoteEnd = clientIp;
  12.  
  13.             while(!s.Connected)
  14.             {
  15.                 //maybe add timeout
  16.                 Thread.Sleep(1000);
  17.                 try
  18.                 {
  19.                     s.Connect(remoteEnd);
  20.                 }
  21.                 catch { }
  22.                 Console.WriteLine("Successful connection for sending at  " + remoteEnd);
  23.  
  24.                
  25.             }
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement