ladybird/Kernel/LocalSocket.h
Andreas Kling bf58241c11 Port the WindowServer and LibGUI to communicate through local sockets.
This is really cool! :^)

Apps currently refuse to start if the WindowServer isn't listening on the
socket in /wsportal. This makes sense, but I guess it would also be nice
to have some sort of "wait for server on startup" mode.

This has performance issues, and I'll work on those, but this stuff seems
to actually work and I'm very happy with that.
2019-02-14 17:18:35 +01:00

36 lines
991 B
C++

#pragma once
#include <Kernel/Socket.h>
#include <Kernel/DoubleBuffer.h>
class FileDescriptor;
class LocalSocket final : public Socket {
public:
static RetainPtr<LocalSocket> create(int type);
virtual ~LocalSocket() override;
virtual bool bind(const sockaddr*, socklen_t, int& error) override;
virtual bool connect(const sockaddr*, socklen_t, int& error) override;
virtual bool get_address(sockaddr*, socklen_t*) override;
virtual bool can_read(SocketRole) const override;
virtual ssize_t read(SocketRole, byte*, size_t) override;
virtual ssize_t write(SocketRole, const byte*, size_t) override;
virtual bool can_write(SocketRole) const override;
private:
explicit LocalSocket(int type);
virtual bool is_local() const override { return true; }
RetainPtr<FileDescriptor> m_file;
RetainPtr<LocalSocket> m_peer;
bool m_bound { false };
sockaddr_un m_address;
DoubleBuffer m_for_client;
DoubleBuffer m_for_server;
};