summaryrefslogtreecommitdiffstats
path: root/deps/include/spdlog/details/udp_client.h
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-06-28 01:59:49 +0500
committeruntodesu <kirill@untode.su>2025-06-28 01:59:49 +0500
commit61e5bcef2629e2d68b805a956a96fff264d4f74d (patch)
treebca3a94bac79d34e3c0db57c77604f5a823ecbda /deps/include/spdlog/details/udp_client.h
parent88c01588aa0830e219eaa62588839e4d1e2883ce (diff)
downloadvoxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.tar.bz2
voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.zip
Restructure dependencies and update to C++20
- Nuked static_assert from almost everywhere in the project - Nuked binary dependency support. Might add one later though - Separated dependency headers into a separate include subdirectory - Grafted a thirdpartylegalnotices.txt generator from RITEG - Pushed development snapshot version to 2126 (26th week of 2025)
Diffstat (limited to 'deps/include/spdlog/details/udp_client.h')
-rw-r--r--deps/include/spdlog/details/udp_client.h81
1 files changed, 0 insertions, 81 deletions
diff --git a/deps/include/spdlog/details/udp_client.h b/deps/include/spdlog/details/udp_client.h
deleted file mode 100644
index 07fe2fd..0000000
--- a/deps/include/spdlog/details/udp_client.h
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
-// Distributed under the MIT License (http://opensource.org/licenses/MIT)
-
-#pragma once
-
-// Helper RAII over unix udp client socket.
-// Will throw on construction if the socket creation failed.
-
-#ifdef _WIN32
- #error "include udp_client-windows.h instead"
-#endif
-
-#include <arpa/inet.h>
-#include <cstring>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <netinet/udp.h>
-#include <spdlog/common.h>
-#include <spdlog/details/os.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-#include <string>
-
-namespace spdlog {
-namespace details {
-
-class udp_client {
- static constexpr int TX_BUFFER_SIZE = 1024 * 10;
- int socket_ = -1;
- struct sockaddr_in sockAddr_;
-
- void cleanup_() {
- if (socket_ != -1) {
- ::close(socket_);
- socket_ = -1;
- }
- }
-
-public:
- udp_client(const std::string &host, uint16_t port) {
- socket_ = ::socket(PF_INET, SOCK_DGRAM, 0);
- if (socket_ < 0) {
- throw_spdlog_ex("error: Create Socket Failed!");
- }
-
- int option_value = TX_BUFFER_SIZE;
- if (::setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
- reinterpret_cast<const char *>(&option_value), sizeof(option_value)) < 0) {
- cleanup_();
- throw_spdlog_ex("error: setsockopt(SO_SNDBUF) Failed!");
- }
-
- sockAddr_.sin_family = AF_INET;
- sockAddr_.sin_port = htons(port);
-
- if (::inet_aton(host.c_str(), &sockAddr_.sin_addr) == 0) {
- cleanup_();
- throw_spdlog_ex("error: Invalid address!");
- }
-
- ::memset(sockAddr_.sin_zero, 0x00, sizeof(sockAddr_.sin_zero));
- }
-
- ~udp_client() { cleanup_(); }
-
- int fd() const { return socket_; }
-
- // Send exactly n_bytes of the given data.
- // On error close the connection and throw.
- void send(const char *data, size_t n_bytes) {
- ssize_t toslen = 0;
- socklen_t tolen = sizeof(struct sockaddr);
- if ((toslen = ::sendto(socket_, data, n_bytes, 0, (struct sockaddr *)&sockAddr_, tolen)) ==
- -1) {
- throw_spdlog_ex("sendto(2) failed", errno);
- }
- }
-};
-} // namespace details
-} // namespace spdlog