aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/transport/udp_wsa_zero_copy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/transport/udp_wsa_zero_copy.cpp')
-rw-r--r--host/lib/transport/udp_wsa_zero_copy.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/host/lib/transport/udp_wsa_zero_copy.cpp b/host/lib/transport/udp_wsa_zero_copy.cpp
index 66af394a9..68e94d319 100644
--- a/host/lib/transport/udp_wsa_zero_copy.cpp
+++ b/host/lib/transport/udp_wsa_zero_copy.cpp
@@ -286,6 +286,21 @@ public:
return local_port;
}
+ std::string get_local_addr(void) const {
+ // Behold the beauty of winsock
+ struct sockaddr_in addr_info;
+ int addr_len = sizeof(addr_info);
+ std::string local_addr;
+ if (getsockname(_sock_fd, (SOCKADDR*) &addr_info, &addr_len) == 0) {
+ // inet_ntoa() guarantees either NULL or null-terminated array
+ char *local_ip = inet_ntoa(addr_info.sin_addr);
+ if (local_ip) {
+ local_addr = std::string(local_ip);
+ }
+ }
+ return local_addr;
+ }
+
//! Read back the socket's buffer space reserved for receives
size_t get_recv_buff_size(void) {
int recv_buff_size = 0;