ladybird/Libraries/LibCore/CTCPServer.h
Conrad Pankoff ed66f1d6d4 LibCore: Add CTCPServer
This is pretty much a find/replace copy of CLocalServer, and some
modifications to CTCPSocket and CSocketAddress to support it.
2019-08-05 12:53:07 +02:00

27 lines
558 B
C++

#pragma once
#include <AK/IPv4Address.h>
#include <LibCore/CNotifier.h>
#include <LibCore/CObject.h>
class CTCPSocket;
class CTCPServer : public CObject {
C_OBJECT(CTCPServer)
public:
explicit CTCPServer(CObject* parent = nullptr);
virtual ~CTCPServer() override;
bool is_listening() const { return m_listening; }
bool listen(const IPv4Address& address, u16 port);
CTCPSocket* accept();
Function<void()> on_ready_to_accept;
private:
int m_fd { -1 };
bool m_listening { false };
OwnPtr<CNotifier> m_notifier;
};