mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
ed66f1d6d4
This is pretty much a find/replace copy of CLocalServer, and some modifications to CTCPSocket and CSocketAddress to support it.
27 lines
558 B
C++
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;
|
|
};
|