-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunix_socket.h
58 lines (34 loc) · 901 Bytes
/
unix_socket.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Created by ilya on 25.05.18.
//
#ifndef IPC_UNIX_SOCKET_H
#define IPC_UNIX_SOCKET_H
#include <unistd.h>
#include <string>
struct unix_socket
{
private:
int fd;
explicit unix_socket(int _fd);
public:
// General:
unix_socket() noexcept;
void close();
unix_socket(unix_socket const& other) = delete;
unix_socket& operator=(unix_socket const& other) = delete;
void swap(unix_socket& other);
friend void swap(unix_socket& a, unix_socket& b);
unix_socket(unix_socket&& other) noexcept;
unix_socket& operator=(unix_socket&& other) noexcept;
void create();
~unix_socket();
void send_file_descriptor(int fd);
int get_file_descriptor();
// Client:
void connect(char const* file_name);
// Server:
void bind(const char* file_name);
void listen();
unix_socket accept();
};
#endif //IPC_UNIX_SOCKET_H