On 18 February 2012 09:52, Brian Knox <taotetek@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