tcpclient — creates an outgoing TCP connection.
tcpclient
[opts
] {host
} {port
} {prog
}
opts
is a series of getopt-style options.
host
is one argument.
port
is one argument.
prog
consists of one or more arguments.
tcpclient attempts to connect to a TCP server.
If it is successful, it runs prog
, with descriptor 6 reading from the network and descriptor 7 writing to the network.
It also sets up several environment variables (see tcp-environ(5)).
The server's address is given by host
and port
.
port
may be a name from the /etc/services
table or a number.
host
may be 0, referring to the local machine, or a dotted-decimal IP address, or a host name; it is fed through qualification using dns_ip4_qualify
.
If the server has several IP addresses, tcpclient tries each address in turn.
tcpclient prints messages about failed connection attempts and other problems to standard error.
If all connection attempts fail, it exits with status 111.
On successful connection, the exit status is (of course) whatever the exit status of prog
is.
Quiet. Do not print error messages.
(Default.) Print error messages.
Verbose. Print error messages and status messages.
x
+y
Give up on the connection attempt after x
+y
seconds.
Default: 2+58. When a host has several IP addresses,
tcpclient tries to connect to the first IP address, waits x
seconds, tries to connect to the second IP address, waits x
seconds, etc.; then it retries each address that timed out, waiting y
seconds per address.
You may omit [+y
] to skip the second try.
Before version 0.88, tcpclient will use only x
(default: 60).
localip
Use localip
as the IP address for the local side of the connection; quit if localip
is not available.
Normally tcpclient lets the operating system choose an address.
localport
Use localport
as the TCP port for the local side of the connection; quit if localport
is not available.
Normally tcpclient lets the operating system choose a port.
Delay sending data for a fraction of a second whenever the remote host is responding slowly. This is currently the default, but it may not be in the future; if you want it, set it explicitly.
Never delay sending data; enable the TCP_NODELAY
socket option.
(Default.)
Look up the remote host name in DNS to set the environment variable TCPREMOTEHOST
.
Do not look up the remote host name in DNS; remove the environment variable TCPREMOTEHOST
.
localname
Do not look up the local host name in DNS; use localname
for the environment variable TCPLOCALHOST
.
A common choice for localname is 0.
(Default.)
Attempt to obtain TCPREMOTEINFO
from the remote host.
Do not attempt to obtain TCPREMOTEINFO
from the remote host.
n
Give up on the TCPREMOTEINFO
connection attempt after n
seconds.
Default: 26.