MXVK Vulkan Framework 0.24.0
C++20 Vulkan rendering framework for practical 2D and 3D application development with SDL3.
Loading...
Searching...
No Matches
Relay Class Reference

Public Member Functions

bool listen (std::string_view port)
 Relay ()
void stop ()
 ~Relay ()

Detailed Description

Definition at line 16 of file relay.cpp.

Constructor & Destructor Documentation

◆ Relay()

Relay::Relay ( )
inline

Definition at line 18 of file relay.cpp.

18 {
19 std::cout << "relay: init.\n";
21 }
void mx_socket_ignore_pipe_signal()
Ignore SIGPIPE on platforms that require it.
Definition mxsocket.c:577

◆ ~Relay()

Relay::~Relay ( )
inline

Definition at line 22 of file relay.cpp.

22 {
23 std::cout << "relay: quit.\n";
24 }

Member Function Documentation

◆ listen()

bool Relay::listen ( std::string_view port)
inline

Definition at line 28 of file relay.cpp.

28 {
29 if (sockfd.listen(port, 5)) {
30 active.store(true);
31 std::vector<mxnetwork::Socket> sockets;
32 Messages message(&sockets);
33 std::thread background(std::move(message));
34 while (active.load()) {
35 std::optional<mxnetwork::Socket> new_s = sockfd.accept();
36 if (new_s == std::nullopt) {
37 if (errno == EINTR)
38 continue;
39 active.store(false);
40 continue;
41 }
42 mut.lock();
43 new_s->setblocking(false);
44 sockets.push_back(std::move(*new_s));
45 mut.unlock();
46 }
47 background.join();
48 } else {
49 perror("listen");
50 return false;
51 }
52 return true;
53 }
std::mutex mut
Definition relay.cpp:13
std::atomic< bool > active
Definition relay.cpp:12

◆ stop()

void Relay::stop ( )
inline

Definition at line 25 of file relay.cpp.

25 {
26 active.store(false);
27 }

The documentation for this class was generated from the following file: