working commit
This commit is contained in:
+3
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user