I want to get the behavior of "nc -z host port ; echo $?" with socat, since my network admins have disabled netcat. The purpose is just to test that a TCP connection is open between two servers. How would I go about doing this?
Hi if you want check connection between server with socat try below command and refer link ..
CWsocat [options] <address> <address> CWsocat -V CWsocat -h[h[h]] | -?[?[?]] CWfilan CWprocan
try this link for better understanding.. there are other method to check the connectivity..
nc -z host port just attempt to connect without sending any data, it should be equivalent to
socat /dev/null tcp4:host:port.
I think this can achieve your expected bahaviour with socat:
socat /dev/null tcp4:host:port > /dev/null 2>&1 ; echo $?