1

I am currently trying to write a program in node which keeps sending data at regular intervals.

When i try to do this the browser renders data only after a certain number of characters ( approx 1500 ) , is there a way i can manually flush the data and control browser rendering similar to how we can do in java ( response.flush() ) ???

My Program is

    var h = require("http");

    var s = h.createServer(function (rq,rs) {
        console.log("Created Connection ");
        rs.writeHead(200 , { 'Content-Type' : "text/html" } );
        setInterval(function () { 
            rs.write("<br/>\nHello");
            for( var i=0;i<1000;i++) rs.write("                 ");
        } , 2000 );
    });


    s.listen(3221 , function () {
        console.log("Listening \u001b[32m" ,this ,  "\u001b[0m");       
    });

This will work to constantly show 'Hello' after 2 seconds but if i remove the loop which appends empty space it doesn't work.

0 Answers0