I'm working on a graphical windows application. So solutions on c++ and c# are prefered.
For my application, I need to get the remote address and port from active udp connection from a specific process.
I tried IP Helper
API but the methods for UDP don't give remote address and port.
I've already see these posts Get Destination Ip/Port of active udp Connection? and Remote address of active UDP connections in Windows using IP Helper.
I understand why IP Helper can't do the job (udp is connectionless and need to capture packet) but I found nothing concrete how to accomplish that.
Have you a solution ready to use or something close to it?
As you have already discovered, UDP is connectionless, so the OS doesn't track remote party info, like it does for TCP. Unlike a TCP socket, a UDP socket can communicate with multiple remote parties at a time, where
sendto()
specifies a destination ip/port, andrecvfrom()
reports a sender's ip/port.You need to use a packet capture library, such as libpcap, and manually keep track of the ips/ports of outgoing packets you see.