結論
ipv4で通信する時はinet optionを使いましょう
問題
gen_udp:send/4を使う時{error,eafnosupport}
が出た
Server Side
server.erl
{ok, Socket} = gen_udp:open(9999,
[binary,
inet6,
]).
Client Side
client.erl
{ok, Socket} = gen_udp:open(0, [binary, inet6]).
{ok,Addr} = inet:parse_address("10.12.**.**"). %% ipv4 address
Ret = gen_udp:send(Socket, Addr, 9999, <<"hi">>).
%%{error,eafnosupport}
解決
client.erl
{ok, Socket} = gen_udp:open(0, [binary, inet]).
{ok,Addr} = inet:parse_address("10.12.**.**"). %% ipv4 address
Ret = gen_udp:send(Socket, Addr, 9999, <<"hi">>).
%%ok.
わかったこと
ipv4でudp通信する時、サーバーサイトはinet6 optionにしてもipv4通信を受け入れられますが、クライアントサイトはちゃんとinet optionにしないとダメです