1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:57:45 +00:00

LibCore: Implement LocalSocket::read_without_waiting

This uses recv with MSG_DONTWAIT to disable blocking operation for a
single call. LibIPC uses this to read in a non-blocking manner from an
otherwise blocking socket.
This commit is contained in:
sin-ack 2022-01-14 13:22:54 +00:00 committed by Ali Mohammad Pur
parent f9847372f3
commit 27b49a60d0
2 changed files with 10 additions and 4 deletions

View file

@ -229,7 +229,7 @@ public:
int fd() const { return m_fd; }
void set_fd(int fd) { m_fd = fd; }
ErrorOr<size_t> read(Bytes);
ErrorOr<size_t> read(Bytes, int flags = 0);
ErrorOr<size_t> write(ReadonlyBytes);
bool is_eof() const { return !is_open() || m_last_read_was_eof; }
@ -412,6 +412,7 @@ public:
ErrorOr<int> receive_fd(int flags);
ErrorOr<void> send_fd(int fd);
ErrorOr<size_t> read_without_waiting(Bytes buffer);
virtual ~LocalSocket() { close(); }