I tried to make server client model as below

on one shell
nc -l -p 8080 this works as a server and on another nc 8080 and this works as a client

all of this is fine ... the problem that if I closed the client the server closes also .. how can I keep server working after terminating client ??


netcat has a -k option that does what the OP wanted a year ago:

From the man pages:

-k      Forces nc to stay listening for another connection after its 
        current connection is completed. It is an error to use this option with‐
        out the -l option.

So this should work:

nc -lk -p 8080

Use a loop:

while :; do
    netcat -l -p 8080 
  • thnx alot it works ^____________^ – khaled salah Oct 20 '14 at 20:33

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.