Last active
October 7, 2024 14:15
-
-
Save phuesler/7501710 to your computer and use it in GitHub Desktop.
Simple tcp server using netcat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Simple tcp server using netcat | |
# - depending on the netcat version either use nc -l 5555 or nc -l -p 5555 | |
# - verify with `telnet locahhost 5555` | |
# - quit the telnet with `ctrl-]` and then type quit | |
# - the while loop is there so reopen the port after a client has disconnected | |
# - supports only one client at a time | |
PORT=5555; | |
while :; do nc -l -p $PORT | tee output.log; sleep 1; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On OSX this is
while :; do nc -l localhost $PORT | tee output.log; sleep 1; done
(or use brew for conventional unix syntax)