1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:57:35 +00:00

LibCore: Add CTCPServer

This is pretty much a find/replace copy of CLocalServer, and some
modifications to CTCPSocket and CSocketAddress to support it.
This commit is contained in:
Conrad Pankoff 2019-08-05 20:47:30 +10:00 committed by Andreas Kling
parent 79e22acb22
commit ed66f1d6d4
6 changed files with 118 additions and 1 deletions

View file

@ -0,0 +1,26 @@
#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;
};