On Tue, Jun 3, 2014 at 8:50 PM, Iñaki Baz Castillo <[email protected]> wrote:
> Hi,
>
> 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.

There is no such function for UDP because of its disconnected nature
but your uv_udp_recv_cb callback receives the sender's address as one
of its arguments.  HTH.

-- 
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.

Reply via email to