working commit

This commit is contained in:
2026-04-22 15:02:00 +02:00
parent 468dc70d7c
commit 321232ae1d
14 changed files with 310 additions and 236 deletions
+3 -3
View File
@@ -18,7 +18,7 @@ extern "C" {
#include <udpclient.hpp>
UDPClient::UDPClient(void){
UDPClient::UDPClient(void) {
sockfd = 0;
rmax = 2024;
};
@@ -53,7 +53,7 @@ std::expected<void, std::string> UDPClient::Send(std::string message) {
servaddr.sin_addr.s_addr = inet_addr(address.c_str());
if (sendto(sockfd, message.data(), message.size(), 0,
(const struct sockaddr*)&servaddr, sizeof(servaddr)) < 0) {
(const struct sockaddr*)&servaddr, sizeof(servaddr)) < 0) {
int errnocopy = errno;
std::string error = std::strerror(errnocopy);
return std::unexpected("Send datagram error: " + error);
@@ -72,7 +72,7 @@ std::expected<std::string, std::string> UDPClient::Recv() {
int rsize = 0;
std::string buffer(rmax, 0);
if((rsize = recvfrom(sockfd, buffer.data(), buffer.size(),
0, (struct sockaddr *)&servaddr, &len)) < 0) {
0, (struct sockaddr *)&servaddr, &len)) < 0) {
int errnocopy = errno;
std::string error = std::strerror(errnocopy);
return std::unexpected("Receive datagram error: " + error);