summaryrefslogtreecommitdiffstats
path: root/src/UDPClient/UDPClient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/UDPClient/UDPClient.cpp')
-rw-r--r--src/UDPClient/UDPClient.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/UDPClient/UDPClient.cpp b/src/UDPClient/UDPClient.cpp
index 1d427ba..b9d55d0 100644
--- a/src/UDPClient/UDPClient.cpp
+++ b/src/UDPClient/UDPClient.cpp
@@ -64,12 +64,21 @@
{
throw udp_client_server_runtime_error(("invalid address or port: \"" + addr + ":" + decimal_port + "\"").c_str());
}
+
f_socket = socket(f_addrinfo->ai_family, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
if(f_socket == -1)
{
freeaddrinfo(f_addrinfo);
throw udp_client_server_runtime_error(("could not create socket for: \"" + addr + ":" + decimal_port + "\"").c_str());
}
+
+ if (connect(f_socket, f_addrinfo->ai_addr, f_addrinfo->ai_addrlen))
+ {
+ close(f_socket);
+ freeaddrinfo(f_addrinfo);
+ throw udp_client_server_runtime_error(("could not connect socket for: \"" + addr + ":" + decimal_port + "\"").c_str());
+ }
+
printf("Created client %d\n", f_port);
}
@@ -140,3 +149,7 @@
int UDPClient::send(const char *msg, std::size_t size){
return sendto(f_socket, msg, size, 0, f_addrinfo->ai_addr, f_addrinfo->ai_addrlen);
}
+
+ int UDPClient::msend(int n, struct mmsghdr *msg){
+ return sendmmsg(f_socket, msg, n, 0);
+ }