【发布时间】:2015-04-28 01:49:37
【问题描述】:
使用 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): 连接被拒绝
如何解决此错误?
【问题讨论】:
-
哪个操作系统? BSD 和 GNU/Linux netcats 完全不同