Process update and UdpSocket
CI / GCC 16 / C++26 / default (pull_request) Has been cancelled
CI / GCC 16 / C++26 / sanitizers (pull_request) Has been cancelled
CI / GCC 16 / C++26 / werror (pull_request) Has been cancelled

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 21:40:52 +03:00
1 parent 827c9e150a
commit 7ca0e1b62e
5 files changed
+241 -1

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
#pragma once
#include <Void/Functional/Error.hpp>
#include <Void/Functional/Result.hpp>
#include <chrono>
#include <cstdint>
#include <span>
#include <string_view>
namespace Void::Net
{
class UdpSocket final
{
public:
UdpSocket() noexcept = default;
~UdpSocket();
UdpSocket(UdpSocket&& other) noexcept;
UdpSocket& operator=(UdpSocket&& other) noexcept;
UdpSocket(const UdpSocket&) = delete;
UdpSocket& operator=(const UdpSocket&) = delete;
[[nodiscard]] static Void::Result::Result<UdpSocket, Void::Result::Error>
connect(std::string_view host, std::uint16_t port);
[[nodiscard]] bool valid() const noexcept { return handle_ >= 0; }
[[nodiscard]] int native_handle() const noexcept { return handle_; }
void close() noexcept;
void shutdown() noexcept;
[[nodiscard]] Void::Result::Result<bool, Void::Result::Error>
wait_readable(std::chrono::milliseconds timeout) const;
[[nodiscard]] Void::Result::Result<std::size_t, Void::Result::Error>
send(std::span<const std::uint8_t> bytes);
[[nodiscard]] Void::Result::Result<std::size_t, Void::Result::Error>
receive(std::span<std::uint8_t> destination);
private:
explicit UdpSocket(int handle) noexcept : handle_(handle) {}
int handle_{-1};
};
}
+7
View File
@@ -63,4 +63,11 @@ namespace Void::Process
shell(std::string_view command,
std::chrono::milliseconds timeout = std::chrono::milliseconds{0});
/// Replace the current process image while preserving its PID and inherited
/// environment. Returns only when the platform does not support re-exec or
/// exec fails.
[[nodiscard]] Void::Result::Result<void, Void::Result::Error>
reexec(const std::filesystem::path& executable,
const std::vector<std::string>& arguments);
} // namespace Void::Process