Availability:
:- use_module(library(socket)).(can be autoloaded)- reuseaddr
- Allow servers to reuse a port without the system being completely sure the port is no longer in use.
- bindtodevice(+Device:atom)
- Bind the socket to the indicated device. For example, the code below
binds the socket to the loopback device that is typically used
to realise the localhost. See the manual pages for setsockopt()
and the socket interface (e.g., socket(7) on Linux) for details.
tcp_socket(Socket), tcp_setopt(Socket, bindtodevice(lo)),Note that this call requires root privileges, see library(uid). Also note that you can restrict a socket using
tcp_bind(Socket, IP:Port), where IP is the numeric IP address or DNS name of that address. For examples,tcp_bind(Socket, localhost:Port)also restricts access to local connections. - nodelay
- Same as
nodelay(true) - nodelay(Bool)
- If
true, disable the Nagle optimization on this socket, which is enabled by default on almost all modern TCP/IP stacks. The Nagle optimization joins small packages, which is generally desirable, but sometimes not. Please note that the underlying TCP_NODELAY setting to setsockopt() is not available on all platforms and systems may require additional privileges to change this option. If the option is not supported, tcp_setopt/2 raises a domain_error exception. See Wikipedia for details. - broadcast
- UDP sockets only: broadcast the package to all addresses matching the address. The address is normally the address of the local subnet (i.e. 192.168.1.255). See udp_send/4.
- dispatch(Bool)
- In GUI environments (using XPCE or the Windows plwin.exe executable)
this flags defines whether or not any events are dispatched on behalf of
the user interface. Default is
true. Only very specific situations require setting this tofalse.