Skip to content
Welcome to the new CppUtils documentation!
ShutdownMode;
using CppUtils::Network::Socket::NativeSocket = int;
[[nodiscard]] auto Socket::getDomain() const noexcept -> Domain;
[[nodiscard]] auto Socket::getType() const noexcept -> Type;
[[nodiscard]] auto Socket::isBlocking() const noexcept -> bool;
[[nodiscard]] auto Socket::isValid() const noexcept -> bool;
explicit Socket::Socket( Domain domain = Domain::IPV4, Type type = Type::TCP);
explicit Socket::Socket( NativeSocket socket, Domain domain = Domain::IPV4, Type type = Type::TCP) noexcept;
Socket::Socket(const Socket&) = delete;
Socket::Socket(Socket&& other) noexcept;
auto Socket::operator=(const Socket&) -> Socket& = delete;
auto Socket::operator=(Socket&& other) noexcept -> Socket&;
virtual Socket::~Socket();
[[nodiscard]] auto Socket::shutdown(ShutdownMode mode = ShutdownMode::Both) const -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::getRemoteEndpoint() const -> std::expected<Endpoint, std::error_code>;
[[nodiscard]] auto Socket::getLocalEndpoint() const -> std::expected<Endpoint, std::error_code>;
[[nodiscard]] auto Socket::setIPv6Only(bool enable) const -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::setReuseAddress(bool enable) const -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::setBlocking(bool enable) -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::isReadyForRead(const Chrono::Duration auto& timeout) const -> bool;
template <class T>
[[nodiscard]] auto Socket::getSocketOption(int level, int option) const -> std::expected<T, std::error_code>;
[[nodiscard]] auto Socket::checkPendingError() const -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::send(const void* data, std::size_t size) -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::sendDatagram(const void* data, std::size_t size, std::string_view ip, std::uint16_t port) -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::send(std::string_view string) -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::send(const std::vector<std::byte>& data) -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::sendDatagram(std::string_view string, std::string_view ip, std::uint16_t port) -> std::expected<void, std::error_code>;
[[nodiscard]] auto Socket::send(const CppUtils::Type::TriviallyCopyable auto& data) -> std::expected<void, std::error_code>;
template <class T>
[[nodiscard]] auto Socket::receive([[maybe_unused]] std::size_t bufferSize = 1'024) -> std::expected<T, std::error_code>;
[[nodiscard]] auto Socket::receive<std::vector<std::byte>>(std::size_t bufferSize) -> std::expected<std::vector<std::byte>, std::error_code>;
[[nodiscard]] auto Socket::receive<std::string>(std::size_t bufferSize) -> std::expected<std::string, std::error_code>;
[[nodiscard]] auto Socket::receiveDatagram(std::size_t udpBufferSize = 4'096uz) -> std::expected<Datagram, std::error_code>;
[[nodiscard]] static auto Socket::isDisconnectError(const std::error_code& error) noexcept -> bool;