1
これは私のルビーサーバーです:ノードnetソケット経由でRuby TCPサーバーを接続する方法は?
require "socket"
server=TCPServer.open(2000)
loop{
puts "wait for connect"
client=server.accept
puts "connect"
client.puts(Time.now.ctime)
client.close
}
と私は仕事の罰金であるルビークライアントwrited:
require "socket"
s=TCPSocket.open("localhost",2000)
while line=s.gets
puts line.chop
end
s.close
をしかし、私が代わりにノードソケットを使用する場合、私はError: connect ECONNREFUSED
を得ました。
これは私のノードのコードです:
var client, net;
net = require("net");
client = net.createConnection(2000);
console.log("connected");
client.on("data", function (data) {
console.log(data);
});
client.on("end", function() {
return console.log("client closed");
});
は、私が行っていた何かが間違っているのですか?
'netstat -anp |の出力は何ですか? grep 2000'? – sarnold
何もありません! – island205
あなたのサーバーはもう稼働していませんか? – sarnold