Re: /dev/tcp

Eli the Bearded <*@eli.users.panix.com>
Newsgroups comp.os.linux.misc
Organization Some absurd concept
Message-ID <[email protected]>
In comp.os.linux.misc, Lawrence DOliveiro <[email protected]> wrote:
> On Wed, 19 Aug 2026 21:20:56 -0000 (UTC), Eli the Bearded wrote:
>> What system(s) have /dev/tcp/* natively?
> Not sure what the point of it is, when you have this
> <https://manpages.debian.org/socat(1)>.

This came up in the context of "how to test network on a system with no
root and no helpful utilities installed."

Normally I use, in preferential order: telnet, nc, perl[*], then curl to
test arbitrary sockets. If I know it runs a webserver, curl will be
first. In this case none of those were installed, and someone came up
with a jshell solution. Bash sockets were discussed, but also ruled out
because bash was not installed.

With jshell, the Java shell, something like this will print "Worked"
if it works:

  var s=new java.net.Socket();
  s.connect(new java.net.InetSocketAddress("www.google.com", 80), 3000);
  System.out.println("Worked");
  s.close();

And if it doesn't work, you get something like:

  |  Exception java.net.SocketTimeoutException: Connect timed out
  |        at NioSocketImpl.timedFinishConnect (NioSocketImpl.java:551)
  |        at NioSocketImpl.connect (NioSocketImpl.java:602)
  |        at SocksSocketImpl.connect (SocksSocketImpl.java:327)
  |        at Socket.connect (Socket.java:633)
  |        at (#2:1)

I was curious if there exist systems where any process that can open
a file (eg, /bin/sh) could use /dev/tcp to test sockets. I don't have
a real need, just a burning curiosity.

Elijah
------
[*] knows you can use python, too, but doesn't have the code to do so memorized
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.