//_________________________________________________________________________ private void BTCP_TCP_Click(object sender, EventArgs e) { try { if (Server == null) { Server = new CTCPlistener(CBIP1.Text, (int)UDPort1.Value, ref EvSendAnswerToServer, this); if (Server.IsConnect) { Server.EvGetData += Server1_GetData; BConnect1.Text = "Разъединить"; if (bAddActiveIP) { Properties.Settings.Default.asIPactiveList = String.Join(";", Properties.Settings.Default.asIPactiveList, CBIP1.Text); } } else { OutMess($"Нет соединения с {CBIP1.Text}:{UDPort1.Value}"); } } else { ServerClose(); Inv_OutMess($"Откл. {CBIP1.Text}"); BConnect1.Text = "Соединить"; } } catch (Exception exc) { Inv_OutMess($"{CBIP1.Text}: {exc.Message}{Environment.NewLine}{exc.StackTrace}"); } }
//_________________________________________________________________________ private void ServerClose() { if (Server != null) { Server.Close(); Server = null; } }