mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibCore: Implement LocalSocket::receive_fd and send_fd
These are just wrappers over the sendfd and recvfd syscalls.
This commit is contained in:
parent
aaec30ee6e
commit
f9847372f3
2 changed files with 24 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
|
#include <LibCore/System.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
@ -535,4 +536,24 @@ ErrorOr<NonnullOwnPtr<LocalSocket>> LocalSocket::connect(String const& path)
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<int> LocalSocket::receive_fd(int flags)
|
||||||
|
{
|
||||||
|
#ifdef __serenity__
|
||||||
|
return Core::System::recvfd(m_helper.fd(), flags);
|
||||||
|
#else
|
||||||
|
(void)flags;
|
||||||
|
return Error::from_string_literal("File descriptor passing not supported on this platform");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> LocalSocket::send_fd(int fd)
|
||||||
|
{
|
||||||
|
#ifdef __serenity__
|
||||||
|
return Core::System::sendfd(m_helper.fd(), fd);
|
||||||
|
#else
|
||||||
|
(void)fd;
|
||||||
|
return Error::from_string_literal("File descriptor passing not supported on this platform");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -410,6 +410,9 @@ public:
|
||||||
virtual ErrorOr<void> set_blocking(bool enabled) override { return m_helper.set_blocking(enabled); }
|
virtual ErrorOr<void> set_blocking(bool enabled) override { return m_helper.set_blocking(enabled); }
|
||||||
virtual ErrorOr<void> set_close_on_exec(bool enabled) override { return m_helper.set_close_on_exec(enabled); }
|
virtual ErrorOr<void> set_close_on_exec(bool enabled) override { return m_helper.set_close_on_exec(enabled); }
|
||||||
|
|
||||||
|
ErrorOr<int> receive_fd(int flags);
|
||||||
|
ErrorOr<void> send_fd(int fd);
|
||||||
|
|
||||||
virtual ~LocalSocket() { close(); }
|
virtual ~LocalSocket() { close(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue