Re: Why size of sockaddr smaller than size of sockaddr_in6?

From: YOSHIFUJI Hideaki / 吉藤英明
Date: Thu Nov 06 2003 - 22:54:44 EST


In article <37FBBA5F3A361C41AB7CE44558C3448E011959C7@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> (at Fri, 7 Nov 2003 11:00:55 +0800), "Zheng, Jeff" <jeff.zheng@xxxxxxxxx> says:

> Is sockaddr_storage part of IPv6? I mean, does sockaddr_storage exist in a system that does not have IPv6? In such system if I use sockaddr_in6, the compile will be failed because there is no sockaddr_in6 structure.

AFAIK, sockaddr_storage{} was introduced because sockaddr_in6{}
is too large for sockaddr{}. However, the use of sockaddr_storage{}
is not limited to IPv6. Systems which does not support IPv6 may have
sockaddr_storage{}.

BTW, there're little chances for users to use sockaddr_in{} or sockaddr_in6{}.
Modern and "good" applications never use them.

Use getaddrinfo(3) / getnameinfo(3) (which uses addrinfo{} and sockaddr{}).

If you need a structure to hold socket address,
you may use sockaddr_storage{}; i.e. for getsockname(2) / getpeername(2).

If you are UNABLE to avoid touching socket address structure, use it finally;
This is very rare.


Well, this is kernel developmen list. Please change the list.
Thanks.

--
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@xxxxxxxxxxxxxx>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/