Stop node.js program from command line

后端 未结 19 2279
无人及你
无人及你 2020-11-29 14:51

I have a simple TCP server that listens on a port.

var net = require(\"net\");

var server = net.createServer(function(socket) {
    socket.end(\"Hello!\\n\"         


        
19条回答
  •  迷失自我
    2020-11-29 14:58

    To end the program, you should be using Ctrl + C. If you do that, it sends SIGINT, which allows the program to end gracefully, unbinding from any ports it is listening on.

    See also: https://superuser.com/a/262948/48624

提交回复
热议问题