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]] | -?[?[?]]

try this link for better understanding.. there are other method to check the connectivity..

  • It's just socat's man page. Doesn't answer the question. – user666412 Sep 13 '16 at 13:49

Since 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 $?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.