I am new to nodeJs, the below program does not terminates any sugestions..

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

    for(i=0;i<=10000;i++){
    var socket = new net.Socket();
    socket.connect(i, "localhost", function() {
    console.log(i+" Port is open");
    socket.destroy();

    });
    socket.on("error", function() {
    console.log(i+" Port is closed: ");
    socket.destroy();
    });
    }

```