diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-14 15:17:30 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-14 15:17:30 +0100 |
commit | 54b1d6f57fe52de11701e96461a19fd2750fd2d4 (patch) | |
tree | 952cec4305680d4e65fb6200106ef126e5d9ce0f /Kernel/Socket.h | |
parent | 1d66670ad7add1e9e9073413136fc48528c90157 (diff) | |
download | serenity-54b1d6f57fe52de11701e96461a19fd2750fd2d4.zip |
Kernel: More sockets work. Fleshing out accept().
Diffstat (limited to 'Kernel/Socket.h')
-rw-r--r-- | Kernel/Socket.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Kernel/Socket.h b/Kernel/Socket.h index a6c8809f36..d5e91cfb52 100644 --- a/Kernel/Socket.h +++ b/Kernel/Socket.h @@ -1,7 +1,10 @@ #pragma once +#include <AK/Lock.h> #include <AK/Retainable.h> #include <AK/RetainPtr.h> +#include <AK/HashTable.h> +#include <AK/Vector.h> #include <Kernel/UnixTypes.h> class Socket : public Retainable<Socket> { @@ -9,18 +12,30 @@ public: static RetainPtr<Socket> create(int domain, int type, int protocol, int& error); virtual ~Socket(); + bool is_listening() const { return m_listening; } int domain() const { return m_domain; } int type() const { return m_type; } int protocol() const { return m_protocol; } + bool can_accept() const { return m_pending.is_empty(); } + RetainPtr<Socket> accept(); + + bool listen(int backlog, int& error); + virtual bool bind(const sockaddr*, socklen_t, int& error) = 0; + virtual bool get_address(sockaddr*, socklen_t*) = 0; protected: Socket(int domain, int type, int protocol); private: + Lock m_lock; int m_domain { 0 }; int m_type { 0 }; int m_protocol { 0 }; -}; + int m_backlog { 0 }; + bool m_listening { false }; + Vector<RetainPtr<Socket>> m_pending; + Vector<RetainPtr<Socket>> m_clients; +}; |