我在 bash(1) 手册页中注意到了这一点。是否有提供此接口的操作系统或某些内核模块?在我的 Debian 安装上尝试过,但这些设备不存在。
谢谢
/dev/tcp/host/port
If host is a valid hostname or Internet address, and port is an integer port number or service
name, bash attempts to open the corresponding TCP socket.
/dev/udp/host/port
If host is a valid hostname or Internet address, and port is an integer port number or service
name, bash attempts to open the corresponding UDP socket.
Run Code Online (Sandbox Code Playgroud)
解决方案/答案:这是有效的,它是外壳的一个功能。去测试:
$ nc -l -p 5555
echo Hello > /dev/tcp/localhost/5555
$ nc -l -p 5555
Hello
Run Code Online (Sandbox Code Playgroud)
很酷。