Establish a TCP communication as a client. The +,-,+ mode is the
preferred way for a client to establish a connection. This predicate
can be hooked to support network proxies. To use a proxy, the hook
proxy_for_url/3 must be defined. Permitted options are:
- bypass_proxy(+Boolean)
- Defaults to
false. If true, do not attempt to use any
proxies to obtain the connection
- nodelay(+Boolean)
- Defaults to
false. If true, set nodelay on the
resulting socket using tcp_setopt(Socket, nodelay)
- domain(+Domain)
- One of `inet' or
inet6. When omitted we use host_address/2
with type(stream) and try the returned addresses in order.
The +,+,- mode is deprecated and does not support proxies. It
behaves like tcp_connect/4, but creates a stream pair (see
stream_pair/3).
- Arguments:
-
| Address | - is either a Host:Port term or a file name (atom or
string). The latter connects to an AF_UNIX socket and requires
unix_domain_socket/1. |
- Errors
- -
proxy_error(tried(ResultList)) is raised by mode (+,-,+) if
proxies are defines by proxy_for_url/3 but no proxy can establsh the
connection. ResultList contains one or more terms of the form
false(Proxy) for a hook that simply failed or error(Proxy,
ErrorTerm) for a hook that raised an exception.
- See also
- - library(http/http_proxy) defines a hook that allows to connect
through HTTP proxies that support the
CONNECT method.