lib/net/tcp_client/tcp_client.rb
def write(data, timeout = write_timeout)
      data = data.to_s
      if respond_to?(:logger)
        payload        = {timeout: timeout}
        # With trace level also log the sent data
        payload[:data] = data if logger.trace?
        logger.benchmark_debug('#write', payload: payload) do
          payload[:bytes] = socket_write(data, timeout)
        end
      else
        socket_write(data, timeout)
      end
    rescue Exception => exc
      close if close_on_error
      raise exc
    end
def write(data, timeout = write_timeout)
      data = data.to_s
      if respond_to?(:logger)
        payload        = {timeout: timeout}
        # With trace level also log the sent data
        payload[:data] = data if logger.trace?
        logger.benchmark_debug('#write', payload: payload) do
          payload[:bytes] = socket_write(data, timeout)
        end
      else
        socket_write(data, timeout)
      end
    rescue Exception => exc
      close if close_on_error
      raise exc
    end
Write data to the server

 Use #with_retry to add resilience to the #write method

 Raises Net::TCPClient::ConnectionFailure whenever the write fails
        For a description of the errors, see Socket#write

 Parameters
   timeout [Float]
     Optional: Override the default write timeout for this write
     Number of seconds before raising Net::TCPClient::WriteTimeout when no data has
     been written.
     A value of -1 will wait forever
     Default: :write_timeout supplied to #initialize

  Note: After a Net::TCPClient::ReadTimeout #read can be called again on
        the same socket to read the response later.
        If the application no longer wants the connection after a
        Net::TCPClient::ReadTimeout, then the #close method _must_ be called
        before calling _connect_ or _retry_on_connection_failure_ to create
        a new connection