summaryrefslogtreecommitdiff
path: root/Kernel/LocalSocket.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-14 16:01:08 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-14 16:01:45 +0100
commiteb1c721ef343c065d871499c248fb5b754276293 (patch)
treead2426addcc9d2c535b68ab953dbc83e11acef5a /Kernel/LocalSocket.cpp
parentb20a7aca612b705e47fc15d1b1c9b864c6acda61 (diff)
downloadserenity-eb1c721ef343c065d871499c248fb5b754276293.zip
Kernel: Actually send things between the socket endpoints.
Diffstat (limited to 'Kernel/LocalSocket.cpp')
-rw-r--r--Kernel/LocalSocket.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/Kernel/LocalSocket.cpp b/Kernel/LocalSocket.cpp
index 2fb0f3de1c..055ef40fd5 100644
--- a/Kernel/LocalSocket.cpp
+++ b/Kernel/LocalSocket.cpp
@@ -94,3 +94,35 @@ RetainPtr<Socket> LocalSocket::connect(const sockaddr* address, socklen_t addres
m_connected = true;
return m_peer;
}
+
+bool LocalSocket::can_read(SocketRole role) const
+{
+ if (role == SocketRole::Accepted)
+ return !m_for_server.is_empty();
+ else
+ return !m_for_client.is_empty();
+}
+
+ssize_t LocalSocket::read(SocketRole role, byte* buffer, size_t size)
+{
+ if (role == SocketRole::Accepted)
+ return m_for_server.read(buffer, size);
+ else
+ return m_for_client.read(buffer, size);
+}
+
+ssize_t LocalSocket::write(SocketRole role, const byte* data, size_t size)
+{
+ if (role == SocketRole::Accepted)
+ return m_for_client.write(data, size);
+ else
+ return m_for_server.write(data, size);
+}
+
+bool LocalSocket::can_write(SocketRole role) const
+{
+ if (role == SocketRole::Accepted)
+ return !m_for_client.is_empty();
+ else
+ return !m_for_server.is_empty();
+}