Node.js: 发送服务器响应失败

Node.js: Sending server response fails

我正在构建一个 node.js 服务器,它在特定端口上接收数据。这工作得很好,但之后我无法发送回复。

服务器:

http.createServer(function(sock) {

    sock.on('data', function(data) {
        console.log('DATA: ' + data);
        sock.write(' saved in the DB');
        db.serialize(function(){
            db.run("INSERT INTO Data values('" + data + "')");
        });

    });

}).listen(PORT, HOST);

错误: http://i.stack.imgur.com/TzeHJ.png

谢谢, 本尼迪克特

您似乎想改用 net.createServer()

var net = require('net');

net.createServer(function(sock) {
    // code here that uses the socket
});