/* * Copyright (c) 2024, Andrew Kaster * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include namespace IPC { class TransportSocket { AK_MAKE_NONCOPYABLE(TransportSocket); AK_MAKE_DEFAULT_MOVABLE(TransportSocket); public: explicit TransportSocket(NonnullOwnPtr socket); ~TransportSocket(); void set_up_read_hook(Function); bool is_open() const; void close(); void wait_until_readable(); ErrorOr transfer(ReadonlyBytes, Vector const& unowned_fds); struct [[nodiscard]] ReadResult { Vector bytes; Vector fds; }; ReadResult read_as_much_as_possible_without_blocking(Function schedule_shutdown); // Obnoxious name to make it clear that this is a dangerous operation. ErrorOr release_underlying_transport_for_transfer(); ErrorOr clone_for_transfer(); private: NonnullOwnPtr m_socket; }; }