//получаем команду с сервера и передаем ее обработчику события private void listner() { while (true) { try { byte[] buffer = new byte[1024]; int bytesRec = _handler.Receive(buffer); string data = Encoding.UTF8.GetString(buffer, 0, bytesRec); handleCommand(data); } catch { Server.EndClient(this); return; } } }
public void Send(string command) { try { int bytesSent = _handler.Send(Encoding.UTF8.GetBytes(command)); if (bytesSent > 0) { Console.WriteLine("Success"); } } catch (Exception exp) { Console.WriteLine("Error with send command: {0}.", exp.Message); Server.EndClient(this); } }
public void Send(string command) { try { int bytesSent = handler.Send(Encoding.UTF8.GetBytes(command)); if (bytesSent > 0) { Console.WriteLine("Успешно"); } } catch (Exception exp) { Console.WriteLine("Произошла ошибка при отправке комманды: {0}.", exp.Message); Server.EndClient(this); } }