Is it possible to listen to a port continuously?
I listen for incoming tcp notifications with following command
sudo nc -l -p 999
But as soon as notification arrives I have to restart listen with same command. Is it possible to listen to port without having to restart command when notifications arrives until user decides to abort listen?
To find what is listening on a TCP/IP port, open a terminal and go to a shell command-line, and use lsof , a command that LiSts Open Files (TCP ports are considered a type of file in UNIX).
The best Linux command to open a port is using nc command. Open the terminal and type nc -l -p port number. The port will be opening on our Linux system.
Sorta outdated question, but came up first on my Google search.
In order for netcat not to shutdown as soon as the first connection is received, you can add the -k
option.
From the man:
-k Forces nc to stay listening for another connection after its current connection is completed. It is an error to use this option without the -l option.
Src: https://superuser.com/a/708133/410908
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With