If you want to close a http server with only one request from a
    brower ,
    send 'Connection: close' header to client for ending the connection.
    To be more safe,  setting maxConnections = 1 is best to avoid
    concurrent
    connections as below.


I noticed that doing 'req.connection.destroy()' would also end the connection. What is the difference? Is this second option also notifying the client of the imminent closing of the connection, or is it just abruptly closing the socket connection?

Node checks 'Connection: close' header. If it exists, socket.destroySoon() is called after 'finish' event so that a write buffer is surly cleared at the time when a connection is closed while 'req.connection.destroy()' just closes it in regardless of the write buffer.

See
https://github.com/joyent/node/blob/master/lib/http.js#L558-L559
https://github.com/joyent/node/blob/master/lib/http.js#L1802-L1803

Note: The 'finish' event and socket.destroySoon() are not public APIs. Do not use them in your program.





--
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to