/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Core { class TCPServer : public Object { C_OBJECT(TCPServer) public: virtual ~TCPServer() override; bool is_listening() const { return m_listening; } bool listen(const IPv4Address& address, u16 port); void set_blocking(bool blocking); RefPtr accept(); Optional local_address() const; Optional local_port() const; Function on_ready_to_accept; private: explicit TCPServer(Object* parent = nullptr); int m_fd { -1 }; bool m_listening { false }; RefPtr m_notifier; }; }