错误提示为function_clause 模式匹配不上 调用函数为inet_tcp:getserv 这个函数只接受integer或者atom类型的参数
一般都是用的ipv4 所以一般都是gen_tcp:listen(Port,Opts) -> inet_tcp:getserv(Port) 你可以在调用gen_tcp前加个打印,io:format("the port is ~w~n",[Port])
你是直接脚本启动的吗? 猜测是 erl -s M F Args 这种形式启动,Args是参数Port 但是命令行参数在vm虚拟机中会作为字符串处理 如果是这种情况,可以erlang:list_to_integer来转换下
在shell先调用inets:start(). ssl:tart().试一试
init(Port) 改成init([Port]),参数的形式错了