tcp-socket-connect — connect a socket to a TCP server and chain
tcp-socket-connect
[--verbose] [--local-name name
] [--local-address address
] [--local-port port
] [--numeric-host] [--numeric-service] [--check-interfaces] [--no-keepalives] [--no-kill-IP-options] [--no-delay] {host
} {service
} {next-prog
}
tcp-socket-connect is a chain-loading utility that opens a TCP socket, connects it to host
and service
with connect(1), sets the socket to file descriptors 6 and 7 (closing whatever those descriptors were), and then chain loads to next-prog
with the execvp(3) function.
It sets up various conventional UCSPI environment variables that describe the local and remote ends of the connection.
By UCSPI convention the chained-to program is expected to use file descriptor 6 for reading from the server and file descriptor 7 for writing to the server.
next-prog
may contain its own command line options, which tcp-socket-connect will ignore.
If the --numeric-host command line option is used, then no name lookup is done on host
and it must be (a human readable form of) an IP address.
If the --numeric-service command line option is used, then no name lookup is done on service
and it must be a port number.
Otherwise, host
is looked up using the system name resolution facility and port
can be an alphanumeric service name.
The --check-interfaces option prevents the use of any IPv4 addresses if there are no IPv4 addresses on any network interface, and the use of any IPv6 addresses if there are no IPv6 addresses. This isn't particularly useful on a dynamically configured system where network interface IP addresses can come and go.
Following the UCSPI conventions, tcp-socket-connect sets up several environment variables containing information about the TCP connection.
PROTO
This always has the value TCP
.
TCPLOCALIP
The local (client) IP address of the connecting socket, in human-readable form.
Normally, the operating system assigns this; but an explicit assignment can be requested with the --local-address command-line option, where address
is a numeric IP address that is available and matches the protocol of the remote end.
TCPLOCALPORT
The local (client) port number of the connecting socket.
Normally, the operating system assigns this; but an explicit assignment can be requested with the --local-port command-line option, where port
is a numeric port number.
TCPLOCALHOST
The value of name
set by the --local-name option; guaranteed unset if that option is not used.
TCPREMOTEIP
The remote (server) IP address of the connected socket, in human-readable form.
TCPREMOTEPORT
The remote (server) port number of the connected socket.
TCPREMOTEINFO
Guaranteed unset.
TCPREMOTEHOST
Guaranteed unset.
If the --verbose option is used, tcp-socket-connect logs information about connections made.
The --no-keepalives , --no-kill-IP-options , and --no-delay command line options set options on the connected socket. The first disables the use of TCP keepalive probes (which are used by default to ensure that dead connections are noticed and eliminated); the second permits IP options (which are removed by default) so that clients can set source routes; and the third disables the "Nagle" delay algorithm used for slow clients.