Availability:
:- use_module(library(socket)).(can be autoloaded)
Adress = 'www.swi-prolog.org':http,
tcp_socket(Socket),
tcp_connect(Socket, Adress, Read, Write),
This predicate can be hooked by defining the multifile-predicate socket:tcp_connect_hook/4. This hook is specifically intented for proxy negotiation. The code below shows the structure of such a hook. The predicates proxy/1 and proxy_connect/3 must be provided by the user.
:- 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).