diff options
author | Conrad Pankoff <deoxxa@fknsrs.biz> | 2019-08-05 20:47:30 +1000 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-05 12:53:07 +0200 |
commit | ed66f1d6d445cb9cc15421a60c85556da9e2aaed (patch) | |
tree | 72abe7a9035dcb3585818bd3e2b97ce77d665030 /Libraries/LibCore/CTCPServer.h | |
parent | 79e22acb225d8aaa4d20540afa50faac17ea29bf (diff) | |
download | serenity-ed66f1d6d445cb9cc15421a60c85556da9e2aaed.zip |
LibCore: Add CTCPServer
This is pretty much a find/replace copy of CLocalServer, and some
modifications to CTCPSocket and CSocketAddress to support it.
Diffstat (limited to 'Libraries/LibCore/CTCPServer.h')
-rw-r--r-- | Libraries/LibCore/CTCPServer.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Libraries/LibCore/CTCPServer.h b/Libraries/LibCore/CTCPServer.h new file mode 100644 index 0000000000..09b3852118 --- /dev/null +++ b/Libraries/LibCore/CTCPServer.h @@ -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; +}; |