-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys.cpp
More file actions
39 lines (32 loc) · 1.1 KB
/
sys.cpp
File metadata and controls
39 lines (32 loc) · 1.1 KB
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
#include <brewtils/sys.h>
size_t brewtils::sys::send(int sockfd, const void *buf, size_t len, int flags) {
try {
return ::send(sockfd, buf, len, flags);
} catch (const std::exception &e) {
logger::warning("Error sending data: " + std::string(e.what()));
} catch (...) {
logger::warning("Error sending data: unknown error");
}
return -1;
}
size_t brewtils::sys::recv(int sockfd, void *buf, size_t len, int flags) {
return ::recv(sockfd, buf, len, flags);
}
int brewtils::sys::socket(int domain, int type, int protocol) noexcept(true) {
return ::socket(domain, type, protocol);
}
int brewtils::sys::listen(int sockfd, int backlog) noexcept(true) {
return ::listen(sockfd, backlog);
}
int brewtils::sys::bind(int sockfd, const struct sockaddr *addr,
socklen_t addrlen) noexcept(true) {
return ::bind(sockfd, addr, addrlen);
}
void brewtils::sys::exitIf(int signal) noexcept(true) {
std::signal(signal, [](int signal) {
logger::info("Received signal: " + std::to_string(signal));
logger::warning("Exiting application now");
std::exit(0);
});
return;
}