chickadee » tcp6 » tcp-connect/ai

tcp-connect/ai aisprocedure

Takes a list of addrinfo objects, obtained from address-information in the socket egg, and connects to each in turn until one succeeds. If a timeout occurs during connection, or a transient error (connection refused, host unreachable) occurs, the next address in the list will be tried. If all addresses fail, the last error encountered is propagated to the caller. If a fatal socket error occurs then we terminate immediately.

(tcp-connect host port) is equivalent to

(tcp-connect/ai (address-information host port))

which may include IPv6 and IPv4 addresses. To connect instead to localhost:22 over IPv4 only:

(tcp-connect/ai (address-information "localhost" 22 family: af/inet))

and to try to connect to the first HTTP mirror that accepts your connection:

 (append (address-information "" 80)
         (address-information "" 80)
         (address-information "" 80)))

Keeping the connect timeout low is probably a good idea in the last case.