?? ipv6.sgml
字號:
<!-- ##### SECTION Title ##### -->IPv6<!-- ##### SECTION Short_Description ##### -->IPv6 policy functions<!-- ##### SECTION Long_Description ##### --><para>The IPv6 module provides functions for setting and getting the "IPv6policy". The IPv6 policy affects domain name resolution and serverbinding. The possible policies are: IPv4 only, IPv6 only, IPv4 thenIPv6, and IPv6 then IPv4. GNet attempts to set the policy whengnet_init() is called based on two environment variables (if set) oron the host's interfaces. This can be overridden by callinggnet_ipv6_set_policy().</para><para>IPv6 policy affects domain name resolution. A domain name can beresolved to several addresses. Most programs will only use the firstaddress in the list. The problem then is what order the addressesshould be in. For example, if there are both IPv4 and IPv6 addressesin the list and the system cannot connect to IPv6 hosts then an IPv6address should not be first in the list. Otherwise, the host willattempt to connect to it and fail. IPv6 policy determines the orderof the list. If the policy is "IPv4 only", only IPv4 addresses willbe returned. If the policy is "IPv6 then IPv4", IPv6 addresses willcome before IPv4 addresses in the list.</para><para>IPv6 policy also affects server binding. When a server socket iscreated, GNet binds to the "any" address by default. There are IPv4and IPv6 "any" addresses. GNet needs to know which one to use. Ifthe IPv6 policy allows IPv6, GNet will use the IPv6 "any" address. Ifthe IPv6 policy allows only IPv4, GNet will use the IPv4 "any"address.</para><para>GNet sets IPv6 policy in gnet_init(). First it checks two environmentvariables: GNET_IPV6_POLICY and IPV6_POLICY. If either is set, ituses the value to set IPv6 policy. Set the value to "4" for%GIPV6_POLICY_IPV4_ONLY, "6" for %GIPV6_POLICY_IPV6_ONLY, "46" for%GIPV6_POLICY_IPV4_THEN_IPV6, or "64" for%GIPV6_POLICY_IPV6_THEN_IPV4.</para><para>If neither environment variable is set, GNet sets the policy based onthe host's interfaces. If there are only IPv4 interfaces, the policyis set to %GIPV6_POLICY_IPV4_ONLY. If there are only IPv6 interfaces,the policy is set to %GIPV6_POLICY_IPV6_ONLY. If there are both, thepolicy is set to %GIPV6_POLICY_IPV4_THEN_IPV6.</para><para>At runtime on Windows, GNet will check to see the computer can supportIPv6. If so it will set the policy to %GIPV6_POLICY_IPV4_THEN_IPV6. Ifnot it will set the policy to %GIPV6_POLICY_IPV4_ONLY. Environment variables are not checked on Windows.</para><!-- ##### SECTION See_Also ##### --><para></para><!-- ##### ENUM GIPv6Policy ##### --><para></para>@GIPV6_POLICY_IPV4_THEN_IPV6: @GIPV6_POLICY_IPV6_THEN_IPV4: @GIPV6_POLICY_IPV4_ONLY: @GIPV6_POLICY_IPV6_ONLY: <!-- ##### FUNCTION gnet_ipv6_set_policy ##### --><para></para>@policy: <!-- ##### FUNCTION gnet_ipv6_get_policy ##### --><para></para>@Returns:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -