#ifndef BASICSOCKET_H #define BASICSOCKET_H #include "Message.h" #include "Options.h" #include #include #include #include namespace ZeroMQ { template class BasicSocket { public: using ImplementationType = typename Service::ImplementationType; BasicSocket(boost::asio::io_context &context, SocketType type); void connect(std::string_view address, boost::system::error_code &error); void connect(std::string_view address); /** * @brief only see the instance is nullptr or not. */ bool connected() const; void bind(std::string_view address, boost::system::error_code &error); void bind(std::string_view address); template void setOption(IntegralOption, const T &value, boost::system::error_code &error); template void setOption(IntegralOption, const T &value); template void setOption(ArrayOption, const std::string_view &buffer, boost::system::error_code &error); template T option(IntegralOption, boost::system::error_code &error) const; template T option(IntegralOption) const; size_t send(boost::asio::const_buffer buffer, SendFlags flags, boost::system::error_code &error); template typename boost::enable_if, size_t>::type send(const ConstBufferSequence &buffers, SendFlags flags, boost::system::error_code &error); template typename boost::enable_if, size_t>::type send(const ConstBufferSequence &buffers, SendFlags flags = SendFlags::None); size_t send(Message &&message, SendFlags flags, boost::system::error_code &error); size_t send(Message &&message, SendFlags flags); std::size_t receive(Message &message, RecvFlags flags, boost::system::error_code &error); std::size_t receive(Message &message, RecvFlags flags = RecvFlags::None); size_t receive(boost::asio::mutable_buffer buffer, RecvFlags flags, boost::system::error_code &error); size_t receive(const boost::asio::mutable_buffer &buffer, RecvFlags flags = RecvFlags::None); template typename boost::enable_if, std::vector>::type receive(const MutableBufferSequence &buffers, RecvFlags flags, boost::system::error_code &error); template typename boost::enable_if, std::vector>::type receive(const MutableBufferSequence &buffers, RecvFlags flags = RecvFlags::None); // void read_handler(const boost::system::error_code& ec,std::size_t bytes_transferred) template void asyncReceive(Message &message, ReadHandler &&handler); template void asyncReceive(const MutableBufferSequence &buffers, ReadHandler &&handler); template size_t receiveMultipart(OutputIt &out, size_t n, RecvFlags flags, boost::system::error_code &error); template void asyncReceiveMultipart(OutputIt out, ReadHandler &&handler); boost::asio::io_context &ioContext() const; ~BasicSocket(); private: Service &m_service; ImplementationType m_impl; }; } // namespace ZeroMQ #include "BasicSocket.inl" #endif // BASICSOCKET_H