Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
454 views
in Technique[技术] by (71.8m points)

ipv6 - When is the hybrid IP notation ::ffff:192.168.1.4 appropriate?

Put another way, if an address is IPv4, why bother to express it as IPv6 at all?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It’s IPv4 expressed through IPv6 so that the application only needs to support one IP stack.

Being able to reference IPv4 addresses through IPv6 notation means I can work on getting IPv6 support really solid in my application, and not have to worry about duplicating effort.

These days some distributions disable IPv4 compatibility by default (e.g. Debian), and also Windows does this by default. To accommodate this as a programmer you should bind two sockets: one IPv4 socket, and one IPv6 socket with the IPV6_V6ONLY flag (which forces it to bind IPv6–only with no IPv4 compatibility, no matter the state of /proc/sys/net/ipv6/bindv6only).

In the comments below, Mike linked me to this great site with info on how you should use sockaddr_storage for AF_–independent programming (which has great relevance whether you decide to go AF_INET6, or decide to use AF_INET and AF_INET6 side by side). Also I like Beej's Guide to Network Programming, which has some similar information too. Recommended reading. Thanks, Mike!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...