public WriteLineAndGetReply ( string data, System.TimeSpan timeout ) : |
||
data | string | |
timeout | System.TimeSpan | |
Результат |
public static void start(string ip) { client = new SimpleTCP.SimpleTcpClient(); client.StringEncoder = Encoding.UTF8; client.DataReceived += clientData; client.Connect(ip, 10757); client.WriteLineAndGetReply("Send all peds", new TimeSpan(0, 0, 20)); }
private void buttonConnect_Click(object sender, EventArgs e) { statusTextBox.Visible = true; try { client.Connect(txtHost.Text, Convert.ToInt32(txtPort.Text)); statusTextBox.Text += "Установлено соединение с сервером." + Environment.NewLine; client.WriteLineAndGetReply("Новое подключение", TimeSpan.FromSeconds(1)); buttonConnect.Enabled = false; buttonSend.Enabled = true; buttonDisconnect.Enabled = true; } catch (Exception ex) { statusTextBox.Text += ex.Message; buttonConnect.Enabled = true; buttonDisconnect.Enabled = false; } }