1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

LibCore: Add CLocalServer, a server-only local socket class.

Instead of trying to support both client and server in CLocalSocket, let's
have a specialized server class.

The basic usage is:

    CLocalServer server;
    server.listen("/tmp/name-of-portal");
    server.on_ready_to_accept = [&] {
        CLocalSocket* client = server.accept();
        ...
    };

This will make things a lot simpler, since an accepting socket doesn't need
half of the stuff that a regular CIODevice provides. :^)
This commit is contained in:
Andreas Kling 2019-07-27 10:21:25 +02:00
parent 9b7e1eb287
commit b3fe9cde52
5 changed files with 93 additions and 0 deletions

View file

@ -2,6 +2,14 @@
#include <sys/socket.h>
#include <errno.h>
CLocalSocket::CLocalSocket(Badge<CLocalServer>, int fd, CObject* parent)
: CSocket(CSocket::Type::Local, parent)
{
set_fd(fd);
set_mode(CIODevice::ReadWrite);
set_error(0);
}
CLocalSocket::CLocalSocket(CObject* parent)
: CSocket(CSocket::Type::Local, parent)
{