6.4 TCP socket predicates
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog C-library
        • library(socket): Network socket (TCP and UDP) library
          • TCP socket predicates
            • tcp_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
            • tcp_connect/4
            • tcp_connect/3
            • tcp_select/3
            • try_proxy/4
            • proxy_for_url/3
            • tcp_setopt/2
            • tcp_fcntl/3
            • tcp_getopt/2
            • tcp_host_to_address/2
            • gethostname/1
            • negotiate_socks_connection/2
Availability::- use_module(library(socket)).(can be autoloaded)
Source[det]tcp_connect(+Socket, +Address, -Read, -Write)
Connect a (client) socket to Address and return a bi-directional connection through the stream-handles Read and Write. This predicate may be hooked by defining socket:tcp_connect_hook/4 with the same signature. Hooking can be used to deal with proxy connections. E.g.,
:- multifile socket:tcp_connect_hook/4.

socket:tcp_connect_hook(Socket, Address, Read, Write) :-
    proxy(ProxyAdress),
    tcp_connect(Socket, ProxyAdress),
    tcp_open_socket(Socket, Read, Write),
    proxy_connect(Address, Read, Write).
deprecated
New code should use tcp_connect/3 called as tcp_connect(+Address, -StreamPair, +Options).