- Documentation
- Reference manual
- Packages
- SWI-Prolog C-library
- library(socket): Network socket (TCP and UDP) library
- Socket predicate reference
- socket_create/2
- tcp_socket/1
- unix_domain_socket/1
- tcp_close_socket/1
- tcp_open_socket/2
- tcp_open_socket/3
- tcp_bind/2
- tcp_listen/2
- tcp_accept/3
- tcp_connect/2
- rewrite_host/3
- tcp_connect/4
- tcp_connect/3
- tcp_select/3
- try_proxy/4
- proxy_for_url/3
- udp_socket/1
- udp_receive/4
- udp_send/4
- tcp_setopt/2
- tcp_fcntl/3
- tcp_getopt/2
- host_address/3
- tcp_host_to_address/2
- gethostname/1
- ip_name/2
- negotiate_socks_connection/2
- Socket predicate reference
- library(socket): Network socket (TCP and UDP) library
- SWI-Prolog C-library
- reuseaddr
- Allow servers to reuse a port without the system being completely sure the port is no longer in use.
- bindtodevice(+Device)
- Bind the socket to Device (an atom). 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))
- nodelay
- nodelay(true)
- 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 tosetsockopt()
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.
- ip_add_membership(+MultiCastGroup)
- ip_add_membership(+MultiCastGroup, +LocalInterface)
- ip_add_membership(+MultiCastGroup, +LocalInterface, +InterfaceIndex)
- ip_drop_membership(+MultiCastGroup)
- ip_drop_membership(+MultiCastGroup, +LocalInterface)
- ip_drop_membership(+MultiCastGroup, +LocalInterface, +InterfaceIndex)
- Join/leave a multicast group. Calls
setsockopt()
with the corresponding arguments. - dispatch(+Boolean)
- In GUI environments (using XPCE or the Windows
swipl-win.exe
executable) this flags defines whether or not any events are dispatched on behalf of the user interface. Default istrue
. Only very specific situations require setting this tofalse
. - sndbuf(+Integer)
- Sets the send buffer size to Integer (bytes). On Windows this defaults (now) to 64kb. Higher latency links may benefit from increasing this further since the maximum theoretical throughput on a link is given by buffer-size / latency. See https://support.microsoft.com/en-gb/help/823764/slow-performance-occurs-when-you-copy-data-to-a-tcp-server-by-using-a for Microsoft's discussion