gen_tcp:close/1
关闭一个 TCP 套接字
用法:
close(Socket) -> ok
关闭一个 TCP 套接字。
{Rand, _RandSeed} = random:uniform_s(9999, erlang:now()), Port = 40000 + Rand, case gen_tcp:listen(Port, [binary, {packet, 0}, {active, false}]) of {ok, Socket} -> gen_tcp:close(Socket); _ -> socket_listen_fail end.