Poll: does this violate strict aliasing? struct b { int x; } S; int *p = (int*)&S; *p = 1;
-
-
You could do *(sa_family_t*)((char *)p+offsetof(struct sockaddr, sa_family)) :-)
-
The right solution is treating "struct sockaddr *" as an abstract/opaque type and using it just with getaddrinfo/getnameinfo/bind/connect.
-
That's not an option if you need to e.g. extract a port number from a sockaddr or manipulate/compare an address sadly.
-
Sure it is. getnameinfo (use NI_NUMERICHOST|NI_NUMERICSERV) converts them to string forms you can manipulate and match.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.