//窗口关闭 private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (tcp != null && tcp.IsConnected) { tcp.Close(); } }
public void Close() { if (tcpClient != null && tcpClient.IsConnected) { tcpClient.Close(); } if (opcClient != null) { opcClient.Close(); } }