Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Socket Server in Bash?

Is there a way to quickly bind to a TCP port/ip address and simply print out all information to STDOUT? I have a simple debugging solution which writes things to 127.0.0.1:4444 and I'd like to be able to simply bind up a port from bash and print everything that comes across. Is there an easy way to do this?

like image 541
Naftuli Kay Avatar asked Jan 19 '11 18:01

Naftuli Kay


People also ask

What is $() bash?

$() means: "first evaluate this, and then evaluate the rest of the line". Ex : echo $(pwd)/myFile.txt. will be interpreted as echo /my/path/myFile.txt. On the other hand ${} expands a variable.

How do I open a TCP socket in Linux?

How to open a port on Linux is a common question when testing a firewall-related problem. Today we will use nc command to open a tcp port manually on Linux and check if this port is working or not. The following Linux commands can be used to open a port in Linux. use nc command to open a port in Linux: nc -4 -l 1234.

What is Socat command in Linux?

Socat is a flexible, multi-purpose relay tool. Its purpose is to establish a relationship between two data sources, where each data source can be a file, a Unix socket, UDP, TCP, or standard input.


1 Answers

$ nc -k -l 4444 > filename.out 

see nc(1)

like image 136
Nikolai Fetissov Avatar answered Oct 14 '22 20:10

Nikolai Fetissov