public void Disconnect() { while (IsSending) Thread.Sleep(10); IsConnected = false; if (_stream != null) { try {_stream.Close(); } catch (Exception ex) { } } if (_client != null) { try { _client.Close(); } catch (Exception ex) { } } }
public void Send(string message) { var client = new Client(); client.Connect(Port, (s) => {}); if (!client.IsConnected) return; client.SendAndWait(message); client.Disconnect(); }