/// <summary> /// Sends the provided text to the specified address. /// </summary> /// <param name="address">The address. Can be tcp://host:port, udp://host:port, http://host:port</param> /// <param name="bytes">The bytes to be sent.</param> protected virtual void NetworkSend(string address, byte[] bytes) { lock (this) { if (KeepConnection) { if (_sender != null) { if (_sender.Address != address) { _sender.Close(); _sender = null; } } ; if (_sender == null) { _sender = NetworkSender.Create(address); } try { ChunkedSend(_sender, bytes); } catch (Exception ex) { InternalLogger.Error("Error when sending {0}", ex); _sender.Close(); _sender = null; throw; } } else { NetworkSender sender = NetworkSender.Create(address); try { ChunkedSend(sender, bytes); } finally { sender.Close(); } } } }