summaryrefslogtreecommitdiff
path: root/Kernel/LocalSocket.h
blob: 7ec70b974183e1b13a4dedb8a33339508b87b365 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#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 RetainPtr<Socket> connect(const sockaddr*, socklen_t, int& error) override;
    virtual bool get_address(sockaddr*, socklen_t*) 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 };
    bool m_connected { false };
    sockaddr_un m_address;

    DoubleBuffer m_for_client;
    DoubleBuffer m_for_server;
};