I write one module, which has one loop function, the function will send udp packet forever. i debug the program in erlang console, I want to know how to close the UDP socket ?
or else erlang will always print the debug message in console. thanks!
start() ->
{ok, Sock} = gen_udp:open(0, []),
send(Sock).
send(Sock) ->
gen_udp:send(Sock, "127.0.0.1", 3211, "hello world"),
timer:sleep(5000),
send(Sock).
There are two things to be considered here
the socket.In that case you can
directly use gen_udp:close(Sock).
gen_udp:controlling_process(Sock,Pid)
where Pid is the process id of the
new owner of the socket. Now you can
use gen_udp:close(Sock) from this
process. http://www.erlang.org/doc/man/gen_udp.html