text: #pragma once
  
  #include <cstdint>
  #include <exception>
  #include <queue>
  #include <string>
  
  #include "./streams.hxx"
  #include "./handle.hxx"
  
  
  namespace tikio::net {
      class socket final :
          public handle,
          public streams::sink<std::string>,
          public streams::source<std::string>
      {
          friend ioloop;
      private:
          static handle_type connect(const std::string& host, std::uint16_t port);
  
          std::string sink_op_buffer;
          std::queue<std::string> sink_buffer;
          bool sink_connected;
  
          void on_data(std::string data) override;
          void on_error(const std::exception& error) override;
          void on_end() override;
  
          void on_connected() override;
  
          bool can_read() override;
          bool can_write() override;
  
          void have_read() override;
          void have_write() override;
          void have_error() override;
          void have_close() override;
  
          socket(handle::handle_type hdl, ioloop& aio);
  
      public:
          socket(const socket&) = delete;
          socket& operator=(const socket&) = delete;
          socket(socket&& other);
          socket& operator=(socket&& other);
          ~socket();
  
          class error : public std::runtime_error {
          public:
              inline error() : runtime_error("socket error") {}
          };
      };
  }
  