2014-06-04 11:20 GMT+02:00 Ben Noordhuis <[email protected]>: >> If I bind TCP in 0.0.0.0:80, then a client connects to 127.0.0.1:80, >> and then I call uv_tcp_getsockname() for that client handle, I get >> "127.0.0.1:80" (rather than "0.0.0.0:80"). Of course it makes sense. >> >> However I wonder whether the same is feasible for UDP. >> >> Let's say that I bind a UDP socket in 0.0.0.0:53 and a client sends a >> datagram from 127.0.0.1 to 127.0.0.1:53. I want to get the *real* >> contacted destination IP of that datagram (which is 127.0.0.1 and not >> 0.0.0.0). >> >> However due the disconnected nature of UDP I don't know if that is >> possible or not (in fact I don't have a specific handle for "the >> client datagram"). I assume the answer is "no". Am I wrong? >> >> Thanks a lot. > > Iñaki, I suspect that you're using the wrong function for uv_tcp_t > handles. uv_tcp_getsockname() returns the local address but what you > probably want is uv_tcp_getpeername(), which returns the remote > address.
No. I really want to get the *destination* IP. Again, if I bind and listen into "0.0.0.0" and I receive a TCP connection from 127.0.0.1 then tcp_getsockname() (called on the peer handle) returns 127.0.0.1. If I receive a TCP connection from 1.2.3.4 then tcp_getsockname() (on the peer handle) returns my public IP. But yes, I'm been searching and reading, and seems that there is no way for the same in UDP (there is no way to know which real destination IP the received datagram has arrived to). -- Iñaki Baz Castillo <[email protected]> -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
