Home‎ > ‎Distributed programming‎ > ‎

Using specific range of port # for Erlang Distribution Protocol

  • http://ftp.sunet.se/pub/lang/erlang/doc/apps/erts/erl_dist_protocol.html

$ cat ./start.sh
#!/bin/sh

if [ $# != 3 ] ; then
        echo "Usage: $0 [sname] [from_port#] [to_port#]"
        exit 1
fi
SNAME=$1
FROM=$2
TO=$3

erl -sname ${SNAME} -kernel inet_dist_listen_min ${FROM} inet_dist_listen_max ${TO}

$ ./start.sh foo 51000 52000
Eshell V5.8.2  (abort with ^G)
(foo@myhost)1> net_adm:ping('bar@myhost').
pong
(foo@myhost)2>

$ ./start.sh bar 51000 52000
Eshell V5.8.2  (abort with ^G)
(bar@myhost)1> net_adm:ping('foo@myhost').
pong
(bar@myhost)2>

$ /cygdrive/d/erl5.8.2/erts-5.8.2/bin/epmd -names
epmd: up and running on port 4369 with data:
name bar at port 51001
name foo at port 51000

■一方指定しない場合はepmdにより動的に設定される

$ erl -sname foo
Eshell V5.8.2  (abort with ^G)
(foo@myhost)1>

$ erl -sname bar
Eshell V5.8.2  (abort with ^G)
(bar@myhost)1>

$ /cygdrive/d/erl5.8.2/erts-5.8.2/bin/epmd -names
epmd: up and running on port 4369 with data:
name bar at port 1130
name foo at port 1126
Comments