diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-08 00:52:33 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-08 00:54:43 +0100 |
commit | 2b0b7cc5a478e0081c418118264f9fb9f34dbc8b (patch) | |
tree | 48d7201bc7dcbfdb17d2318f120c4960e065ebb6 /Kernel/Net/Socket.h | |
parent | a3f39fe789380ff0a577083993bbd0cda0e9e55e (diff) | |
download | serenity-2b0b7cc5a478e0081c418118264f9fb9f34dbc8b.zip |
Net: Add a basic sys$shutdown() implementation
Calling shutdown prevents further reads and/or writes on a socket.
We should do a few more things based on the type of socket, but this
initial implementation just puts the basic mechanism in place.
Work towards #428.
Diffstat (limited to 'Kernel/Net/Socket.h')
-rw-r--r-- | Kernel/Net/Socket.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h index 7222d170f5..a0a7e1d209 100644 --- a/Kernel/Net/Socket.h +++ b/Kernel/Net/Socket.h @@ -51,6 +51,9 @@ public: int type() const { return m_type; } int protocol() const { return m_protocol; } + bool is_shut_down_for_writing() const { return m_shut_down_for_writing; } + bool is_shut_down_for_reading() const { return m_shut_down_for_reading; } + enum class SetupState { Unstarted, // we haven't tried to set the socket up yet InProgress, // we're in the process of setting things up - for TCP maybe we've sent a SYN packet @@ -90,6 +93,8 @@ public: bool can_accept() const { return !m_pending.is_empty(); } RefPtr<Socket> accept(); + KResult shutdown(int how); + virtual KResult bind(const sockaddr*, socklen_t) = 0; virtual KResult connect(FileDescription&, const sockaddr*, socklen_t, ShouldBlock) = 0; virtual KResult listen(int) = 0; @@ -153,6 +158,8 @@ private: int m_backlog { 0 }; SetupState m_setup_state { SetupState::Unstarted }; bool m_connected { false }; + bool m_shut_down_for_reading { false }; + bool m_shut_down_for_writing { false }; timeval m_receive_timeout { 0, 0 }; timeval m_send_timeout { 0, 0 }; |