使用 netcat,我需要创建一个简单的服务器来响应简单的 JSON 数据。
首先我尝试使用 HTML 页面:
while true ; do nc -l 8888 < index.html ; done
或者更简单:
netcat -l 8888 < index.html
然后在我的浏览器中我这样做:
http://localhost:8888/index.html
我也尝试使用 netcat 进行连接:
nc -vz 127.0.0.1 8888
其中每一个都会产生“连接被拒绝”的结果:
localhost [127.0.0.1] 8888 (ddi-tcp-1): Connection refused
如何解决此错误?
最佳答案
问题已解决。
我不得不使用
netcat -l -p 8888 < index.html
这样我就可以收听本地端口了。现在我正在工作。
关于http - Netcat 服务器连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29892831/