Reputation: 24851
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).
Upvotes: 1
Views: 562
Reputation: 2640
There are two things to be considered here
Upvotes: 2
Reputation: 5768
To terminate a process you can
exit(Pid,kill).
if you have a receive loop, you can always have a shutdown message that exists the loop.
receive shutdown-> nothing.
Upvotes: 0