Associates a UDP port number (Port) with the calling
process.
The available options are:
list
-
Received Packet is delivered as a list.
binary
-
Received Packet is delivered as a binary.
{ip, ip_address()}
-
If the host has several network interfaces, this option
specifies which one to use.
{ifaddr, ip_address()}
-
Same as {ip, ip_address()}. If the host has several network interfaces, this option
specifies which one to use.
{fd, integer() >= 0}
-
If a socket has somehow been opened without using
gen_udp, use this option to pass the file
descriptor for it.
inet6
-
Set up the socket for IPv6.
inet
-
Set up the socket for IPv4.
{udp_module, module()}
-
Override which callback module is used. Defaults to
inet_udp for IPv4 and inet6_udp for IPv6.
{multicast_if, Address}
-
Set the local device for a multicast socket.
{multicast_loop, true | false}
-
When true sent multicast packets will be looped back to the local
sockets.
{multicast_ttl, Integer}
-
The multicast_ttl option changes the time-to-live (TTL) for
outgoing multicast datagrams in order to control the scope of the
multicasts.
Datagrams with a TTL of 1 are not forwarded beyond the local
network.
Default: 1
{add_membership, {MultiAddress, InterfaceAddress}}
-
Join a multicast group.
{drop_membership, {MultiAddress, InterfaceAddress}}
-
Leave multicast group.
Opt
-
See
inet:setopts/2.
The returned socket Socket is used to send
packets from this port with send/4. When UDP packets arrive
at the opened port, if the socket is in an active mode the packets
are delivered as messages to the controlling process:
{udp, Socket, IP, InPortNo, Packet}
If the socket is not in an active mode, data can be
retrieved via the recv/2,3 calls.
Note that arriving UDP packets that are longer than
the receive buffer option specifies, might be truncated
without warning.
When a socket in {active, N} mode (see
inet:setopts/2 for details) transitions to passive
({active, false}) mode, the controlling process is notified by a
message of the following form:
{udp_passive, Socket}
IP and InPortNo define the address from which
Packet came. Packet is a list of bytes if
the option list was specified. Packet is a
binary if the option binary was specified.
Default value for the receive buffer option is
{recbuf, 8192}.
If Port == 0, the underlying OS assigns a free UDP
port, use inet:port/1 to retrieve it.