使用gen_tcp的正确方法:连接IPv6地址

使用gen_tcp的正确方法:连接IPv6地址

问题描述:

有谁知道如何连接到ipv6的tcp服务器地址。以下尝试但不起作用。使用gen_tcp的正确方法:连接IPv6地址

{ok, Socket} = gen_tcp:connect("2a01:488:67:1000:253d:cd31:0:1", 5000, [{active, false},inet6]). 
{error,enetunreach} 

{ok, Socket} = gen_tcp:connect("[2a01:488:67:1000:253d:cd31:0:1]", 5000, [{active, false},inet6]). 
{error,nxdomain} 

服务器通过IPv4可达虽然。

谢谢。

+0

Erlang之外的服务器是否可以通过IPv6访问?当你说“通过IPv4可达”时,你的意思是在Erlang吗?你的意思是在'gen_tcp:connect'调用中使用(例如)“192.168.1.1”还是其他的? –

+0

是由erlang在ipv4中。 – user3404572

+0

固定。请忽略这是ipv6地址的端口阻塞。谢谢 – user3404572

根据手册页gen_tcp模块,connect/3-4的第一个参数应为inet:socket_address()inet:hostname()的类型。
尝试使用This表单类型。