13
13
compliance with the License. You should have received a copy of the
14
14
Erlang Public License along with this software. If not, it can be
15
15
retrieved online at http://www.erlang.org/.
17
17
Software distributed under the License is distributed on an "AS IS"
18
18
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
19
the License for the specific language governing rights and limitations
24
24
<title>inet</title>
49
49
might be specified in this way. An example of starting an Erlang
50
50
node with all sockets using delayed send could look like this:</p>
52
$ <input>erl -sname test -kernel \\</input>
53
<input>inet_default_connect_options '[{delay_send,true}]' \\</input>
52
$ <input>erl -sname test -kernel \</input>
53
<input>inet_default_connect_options '[{delay_send,true}]' \</input>
54
54
<input>inet_default_listen_options '[{delay_send,true}]'</input></pre>
55
55
<p>Note that the default option <c>{active, true}</c> currently
56
56
cannot be changed, for internal reasons.</p>
220
220
<p>Returns the local hostname. Will never fail.</p>
224
<name>getopts(Socket, Options) -> OptionValues | {error, posix()}</name>
225
<name>getifaddrs() -> {ok,Iflist} | {error,posix}</name>
226
<fsummary>Return a list of interfaces and their addresses</fsummary>
228
<v>Iflist = {Ifname,[Ifopt]}</v>
229
<v>Ifname = string()</v>
230
<v>Ifopt = {flag,[Flag]} | {addr,Addr} | {netmask,Netmask}
231
| {broadaddr,Broadaddr} | {dstaddr,Dstaddr}
232
| {hwaddr,Hwaddr}</v>
233
<v>Flag = up | broadcast | loopback | pointtopoint
234
| running | multicast</v>
235
<v>Addr = Netmask = Broadadddr = Dstaddr = ip_address()</v>
236
<v>Hwaddr = [byte()]</v>
241
Returns a list of 2-tuples containing interface names and the
242
interface's addresses. <c>Ifname</c> is a Unicode string.
243
<c>Hwaddr</c> is hardware dependent, e.g on Ethernet interfaces
244
it is the 6-byte Ethernet address (MAC address (EUI-48 address)).
247
The <c>{addr,Addr}</c>, <c>{netmask,_}</c> and <c>{broadaddr,_}</c>
248
tuples are repeated in the result list iff the interface has multiple
249
addresses. If you come across an interface that has
250
multiple <c>{flag,_}</c> or <c>{hwaddr,_}</c> tuples you have
251
a really strange interface or possibly a bug in this function.
252
The <c>{flag,_}</c> tuple is mandatory, all other optional.
255
Do not rely too much on the order of <c>Flag</c> atoms or
256
<c>Ifopt</c> tuples. There are some rules, though:
259
Immediately after <c>{addr,_}</c> follows <c>{netmask,_}</c>
262
Immediately thereafter follows <c>{broadaddr,_}</c> if
263
the <c>broadcast</c> flag is <em>not</em> set and the
264
<c>pointtopoint</c>flag <em>is</em> set.
267
Any <c>{netmask,_}</c>, <c>{broadaddr,_}</c> or
268
<c>{dstaddr,_}</c> tuples that follow an <c>{addr,_}</c>
269
tuple concerns that address.
274
The <c>{hwaddr,_}</c> tuple is not returned on Solaris since the
275
hardware address historically belongs to the link layer and only
276
the superuser can read such addresses.
279
On Windows, the data is fetched from quite different OS API
280
functions, so the <c>Netmask</c> and <c>Broadaddr</c>
281
values may be calculated, just as some <c>Flag</c> values.
282
You have been warned. Report flagrant bugs.
287
<name>getopts(Socket, Options) -> {ok, OptionValues} | {error, posix()}</name>
225
288
<fsummary>Get one or more options for a socket</fsummary>
227
290
<v>Socket = term()</v>