def write(data, fire_and_forget = true)
      raise NotConnectedError, "no connection to server" unless connected?

      @socket.puts(data)
      @socket.flush

      return true if fire_and_forget
      read
    rescue Errno::EPIPE
      disconnect
      raise BrokenConnectionError, "the connection to the server is lost"
    end
def write(data, fire_and_forget = true)
      raise NotConnectedError, "no connection to server" unless connected?

      @socket.puts(data)
      @socket.flush

      return true if fire_and_forget
      read
    rescue Errno::EPIPE
      disconnect
      raise BrokenConnectionError, "the connection to the server is lost"
    end
Writes data to the TCP server socket

 @param data the data to write
 @param fire_and_forget if true, no response response is expected from server,
           when false, a response from the server will be returned.

 @return the server response data if there is one