Hum. I'm not sure this is ok. `struct sockaddr` is not big enough for IPv6, I think we need to branch depending on the address family, and cast addr to `sockaddr_in` or `sockaddr_in6` to do the memcpy.