I tested on Ubuntu 18.04 LTS the venerable netcat. The netcat comes from OpenBSD:

$ dpkg -l|grep netcat
ii  netcat-openbsd                             1.187-1                             
amd64        TCP/IP swiss army knife

When I use nc -v -v -v -l -p 1234 to open the server and subsequently nc -v -v -v localhost 1234 to open the client, I observe the following behavior:

  • If client is closed with ^C, this will close both the client and the server
  • If server is closed with ^C, this will close only the server without affecting the client

Why is the behavior asymmetric? Shouldn't the client be closed if the server is closed?

It seems that after the server is closed, typing any line of text into the client finally causes the client to close, as well.

  • It's symmetric. Any read or write from/to a closed network connection gets an error. The client will only try to write to the network connection when you type something. – Mark Plotnick Jun 23 '18 at 20:54

Your Answer

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

Browse other questions tagged or ask your own question.