使用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):拒绝连接
如何解决此错误?
发布于 2015-04-27 11:10:19
问题解决了。
我不得不用
netcat -l -p 8888 < index.html这样我就可以听本地的广播了。现在我开始工作了。
发布于 2015-04-27 10:15:57
在浏览器中没有index.html的情况下试一试
$ netcat -l 8888 < index.html在浏览器中使用http://localhost:8888
如果这不起作用,请尝试使用telnet。
$ telnet localhost 8888
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
test
Connection closed by foreign host.我的index.html只包含字符串'test‘。如果无法建立连接,则该问题是网络问题。
https://stackoverflow.com/questions/29892831
复制相似问题