As a clumsy approximation, I can measure the process of resolving a DNS name with:
time getent hosts server.com
and beautifully see how a uncached query can take about 50ms and cached queries about 5ms in average (a pretty cool difference).
But, how can I do the same to measure a simple socket connection? I'm looking for a command like:
time cmd_to_resolve_dns_and_connect_but_no_wait_for_input_or_output
or just
time cmd_to_download --option-to-ignore-everything-after-socket-connect
or just:
cmd_to_download --the-suitable-process-halt-command --option-to-print-time
Any possibility to know the time of connecting to a (HTTP) server is fine for me (I can of course substract to the time the inner DNS name resolution that the command performs; I know that the option parsing and printing consumes time, etc; I don't need an exact measurement, but the command I need it's not for a script, it's for my eyes).
nmap
. There might be a set ofnc
args that allow you to connect and then immediately terminate the connection, but nothing lookin' obvious to me from that manpage.time tcping -n 1 remoteip remoteport