File: net_adm.3

package info (click to toggle)
erlang-manpages 1%3A12.b.3-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,188 kB
  • ctags: 2
  • sloc: makefile: 68; perl: 30; sh: 15
file content (156 lines) | stat: -rw-r--r-- 3,568 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
.TH net_adm 3 "kernel  2.12.3" "Ericsson AB" "ERLANG MODULE DEFINITION"
.SH MODULE
net_adm \- Various Erlang Net Administration Routines
.SH DESCRIPTION
.LP
This module contains various network utility functions\&.

.SH EXPORTS
.LP
.B
dns_hostname(Host) -> {ok, Name} | {error, Host}
.br
.RS
.TP
Types
Host = atom() | string()
.br
Name = string()
.br
.RE
.RS
.LP
Returns the official name of \fIHost\fR, or \fI{error, Host}\fR if no such name is found\&. See also \fIinet(3)\fR\&.
.RE
.LP
.B
host_file() -> Hosts | {error, Reason}
.br
.RS
.TP
Types
Hosts = [Host]
.br
Host = atom()
.br
Reason = term()
.br
.RE
.RS
.LP
Reads the \fI\&.hosts\&.erlang\fR file, see the section \fIFiles\fR below\&. Returns the hosts in this file as a list, or returns \fI{error, Reason}\fR if the file could not be read\&. See \fIfile(3)\fR for possible values of \fIReason\fR\&.
.RE
.LP
.B
localhost() -> Name
.br
.RS
.TP
Types
Name = string()
.br
.RE
.RS
.LP
Returns the name of the local host\&. If Erlang was started with the \fI-name\fR command line flag, \fIName\fR is the fully qualified name\&.
.RE
.LP
.B
names() -> {ok, [{Name, Port}]} | {error, Reason}
.br
.B
names(Host) -> {ok, [{Name, Port}]} | {error, Reason}
.br
.RS
.TP
Types
Name = string()
.br
Port = int()
.br
Reason = address | term()
.br
.RE
.RS
.LP
Similar to \fIepmd -names\fR, see \fIepmd(1)\fR\&. \fIHost\fR defaults to the local host\&. Returns the names and associated port numbers of the Erlang nodes that \fIepmd\fR at the specified host has registered\&.
.LP
Returns \fI{error, address}\fR if \fIepmd\fR is not running\&. See \fIinet(3)\fR for other possible values of \fIReason\fR\&.

.nf
(arne@dunn)1> net_adm:names()\&.

{ok,[{"arne",40262}]}
.fi
.RE
.LP
.B
ping(Node) -> pong | pang
.br
.RS
.TP
Types
Node = node()
.br
.RE
.RS
.LP
Tries to set up a connection to \fINode\fR\&. Returns \fIpang\fR if it fails, or \fIpong\fR if it is successful\&.
.RE
.LP
.B
world() -> [node()]
.br
.B
world(Arg) -> [node()]
.br
.RS
.TP
Types
Arg = silent | verbose
.br
.RE
.RS
.LP
This function calls \fInames(Host)\fR for all hosts which are specified in the Erlang host file \fI\&.hosts\&.erlang\fR, collects the replies and then evaluates \fIping(Node)\fR on all those nodes\&. Returns the list of all found nodes, regardless of the return value of \fIping(Node)\fR\&.
.LP
\fIArg\fR defaults to \fIsilent\fR\&. If \fIArg == verbose\fR, the function writes information about which nodes it is pinging to stdout\&.
.LP
This function can be useful when a node is started, and the names of the other nodes in the network are not initially known\&.
.LP
Failure: \fI{error, Reason}\fR if \fIhost_file()\fR returns \fI{error, Reason}\fR\&.
.RE
.LP
.B
world_list(Hosts) -> [node()]
.br
.B
world_list(Hosts, Arg) -> [node()]
.br
.RS
.TP
Types
Hosts = [Host]
.br
Host = atom()
.br
Arg = silent | verbose
.br
.RE
.RS
.LP
As \fIworld/0, 1\fR, but the hosts are given as argument instead of being read from \fI\&.hosts\&.erlang\fR\&.
.RE
.SH FILES
.LP
The \fI\&.hosts\&.erlang\fR file consists of a number of host names written as Erlang terms\&. It is looked for in the current work directory, the user\&'s home directory, and \fI$OTP_ROOT\fR (the root directory of Erlang/OTP), in that order\&.
.LP
The format of the \fI\&.hosts\&.erlang\fR file must be one host name per line\&. The host names must be within quotes as shown in the following example:

.nf
\&'super\&.eua\&.ericsson\&.se\&'\&.
\&'renat\&.eua\&.ericsson\&.se\&'\&.
\&'grouse\&.eua\&.ericsson\&.se\&'\&.
\&'gauffin1\&.eua\&.ericsson\&.se\&'\&.
^ (new line)
.fi