Skip to content

Instantly share code, notes, and snippets.

@krestenkrab
Created April 19, 2010 13:01
Show Gist options
  • Select an option

  • Save krestenkrab/371020 to your computer and use it in GitHub Desktop.

Select an option

Save krestenkrab/371020 to your computer and use it in GitHub Desktop.
## LOG OF BEAM SESSION [with erl_dist debug output]
pc-226:~ krab$ /sw/bin/erl -name beam
Erlang R13B02 (erts-5.7.3) [source] [smp:2:2] [rq:2] [async-threads:0] [kernel-poll:false]
##
## This does " init ! { self(), get_arguments } " to remote Erlang VM.
##
Eshell V5.7.3 (abort with ^G)
([email protected])1> {init, '[email protected]'} ! {self(), get_arguments}.
##
## The following is just debug output from the handshake
##
{1271,681396,850411} '[email protected]':{inet_tcp_dist,<0.39.0>,setup,'[email protected]'}
{1271,681396,877101} '[email protected]':port_please('[email protected]') -> version 5
{1271,681396,877409} '[email protected]':send_name: node='[email protected]', version=5
{dist_util,<0.39.0>,recv_status,'[email protected]',ok}
{1271,681399,629993} '[email protected]':recv: node='[email protected]', challenge=862099454 version=5
{1271,681399,630302} '[email protected]':send_reply: challenge=1173919914 digest=<<136,81,53,77,239,36,136,10,201,75, 116,21,62,191,28,41>>
{1271,681399,695602} '[email protected]':recv_ack: digest=[142,0,25,138,140,107,122,234,224,95,228,153,169,140,161,130]
{1271,681399,695692} '[email protected]':sum = <<142,0,25,138,140,107,122,234,224,95,228,153,169,140,161,130>>
{1271,681399,698787} '[email protected]':setnode(md5,'[email protected]' #Port<0.462> {normal,'(',32765,')',5})
{<0.37.0>,get_arguments}
##
## Finally, to prove that it works; see that the response is in our msg queue
##
([email protected])2> process_info(self(), messages).
{messages,[{init,[{root,["/sw/lib/erlang/"]},
{home,["/Users/krab"]},
{name,["[email protected]"]}]}]}
([email protected])3>
## LOG OF ERJANG SESSION [with erl_dist debug output]
##
## In this session, we do nothing. So all output is debug info from the
## protocol handshake
##
java -jar erjang-0.1.jar -root /sw/lib/erlang/ -home /Users/krab -name [email protected]
Eshell V5.7.3 (abort with ^G)
([email protected])1>
{"Got name ~p (V~p)~n",['[email protected]',5]}
{"MD5 connection from ~p (V~p)~n",['[email protected]',5]}
{1271,681398,39000} '[email protected]':do_mark_pending(<net_kernel:81>,'[email protected]',{net_address,
{{172,30,121,226},
54669},
"pc-226.trifork.com",
tcp,inet},32765) -> ok
{dist_util,<:465>,send_status,'[email protected]',ok}
{1271,681399,627000} '[email protected]':send: challenge=862099454 version=5
{1271,681399,684000} '[email protected]':recv_reply: challenge=1173919914 digest=[136,81,53,77,239,36,136,10,201,75,
{1271,681399,687000} '[email protected]':sum = <<136,81,53,77,239,36,136,10,201,75,116,21,62,191,28,41>>
{1271,681399,689000} '[email protected]':send_ack: digest=<<142,0,25,138,140,107,122,234,224,95,228,153,169,140,161,130>>
{dist_util,<:465>,accept_connection,'[email protected]'}
{1271,681399,696000} '[email protected]':setnode(md5,'[email protected]' <port:464> {normal,'(',32765,')',5})
received net_message {6,erjang.EExternalPID@c2dab5,'',global_name_server}
received net_message {6,erjang.EExternalPID@a4cb85,'',init}
received tick from '[email protected]'
received tick from '[email protected]'
@krestenkrab
Copy link
Author

Again, this doesn't look like much, but dont be deceived. Most of the distribution code is actually already written in Erlang already (inet_tcp_dist, dist_util, ...), but the complexity is in the implementation of the inet driver; which I really wish I could write in Erlang! It's a big ugly state machine full of concurrency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment