As I'm building my own http module relying on net module, I want to set a timeout for every new socket.
I build the following:
server = net.createServer(function (socket) {
if(server.timeout==null){
server.timeout=120000;
if(server.timeoutCallBack==null){
server.timeoutCallBack=function(){socket.destroy();};
}
}
socket.setTimeout(server.timeout,server.timeoutCallBack());
so if the user of my server, set a new timeout duration , it will use it. if not, it has a default value of 2 minutes.
My problem is that my server doesn't serve the first connection, just the second. I mean, for the first http message it gets, it doesn't invoke my :
socket.on("data", function (data) {
});