From 246c194740e21fda85ad1d406123e679e47d0c8c Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Thu, 13 Apr 2017 16:30:23 -0700 Subject: add windows get_local_port() --- host/lib/transport/udp_wsa_zero_copy.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'host') diff --git a/host/lib/transport/udp_wsa_zero_copy.cpp b/host/lib/transport/udp_wsa_zero_copy.cpp index c1a4f4db6..66af394a9 100644 --- a/host/lib/transport/udp_wsa_zero_copy.cpp +++ b/host/lib/transport/udp_wsa_zero_copy.cpp @@ -275,6 +275,16 @@ public: size_t get_num_send_frames(void) const {return _num_send_frames;} size_t get_send_frame_size(void) const {return _send_frame_size;} + uint16_t get_local_port(void) const { + struct sockaddr_in addr_info; + int addr_len = sizeof(addr_info); + uint16_t local_port = 0; + if (getsockname( _sock_fd, (SOCKADDR*) &addr_info, + &addr_len) == 0){ + local_port = ntohs(addr_info.sin_port); + } + return local_port; + } //! Read back the socket's buffer space reserved for receives size_t get_recv_buff_size(void) { -- cgit v1.2.3