Is htons(port) needed when in uv_ip4_addr() and uv_ip6_addr() ?

137 views
Skip to first unread message

Iñaki Baz Castillo

unread,
Jun 22, 2014, 10:51:53 AM6/22/14
to li...@googlegroups.com
Hi,

Do I need to set the port using htons(port) as second argument for
uv_ip4/6_addr() functions? If so, are there other UV calls in which I
should take care of big/little endian stuff?

Thanks a lot.

--
Iñaki Baz Castillo
<i...@aliax.net>

Fedor Indutny

unread,
Jun 22, 2014, 11:06:22 AM6/22/14
to li...@googlegroups.com
Nope, I don't think that there are any calls that require you to swap endians.


--
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 libuv+un...@googlegroups.com.
To post to this group, send email to li...@googlegroups.com.
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Iñaki Baz Castillo

unread,
Jun 22, 2014, 11:14:20 AM6/22/14
to li...@googlegroups.com
Thanks. Anyhow, I do need to use ntohs() if I want to examine a
sockaddr_in passed to libuv, right? this is:

uv_udp_getsockname(tcp_handle, (struct sockaddr*)&addr, &len);
port = ntohs(((struct sockaddr_in*)&addr)->sin_port);
printf("local port is %d\n", port);

Am I right?

Thanks a lot.

Fedor Indutny

unread,
Jun 22, 2014, 11:23:11 AM6/22/14
to li...@googlegroups.com
Yes, this is correct. :)

Iñaki Baz Castillo

unread,
Jun 22, 2014, 11:34:57 AM6/22/14
to li...@googlegroups.com
Clear. Thanks.
Reply all
Reply to author
Forward
0 new messages