[zeromq-dev] zmq::tcp_listener_t::get_address

Steven McCoy steven.mccoy at miru.hk
Sat Feb 18 16:12:09 CET 2012

On 18 February 2012 09:52, Brian Knox <taotetek at gmail.com> wrote:

> <         port = ntohs( ((struct sockaddr_in6 *)&sa)->sin6_port);
Standard aliasing problem.  I am more concerned that sockaddr is being used
and not sockaddr_storage.

Resolution is to detect the address and copy the entire sock address
structure before accessing.  The compiler will remove redundant code:

                 struct sockaddr_in6 s6;
                 memcpy (&s6, sa, sizeof(s6));
                 sa_port = s6.sin6_port; -- Steve-o
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120218/abcb117d/attachment.htm>

More information about the zeromq-dev mailing list