I am having trouble understanding the difference between net.createserver and http.createserver in node.js.
I have read the documentation for both methods located at th
http.createServer()
sets up a server that handles the HTTP protocol, which is indeed transmitted over tcp. net.createServer()
creates a server that simply understands when a TCP connection has happened, and data has been transmitted, and so on, but doesn't know anything about whether a valid HTTP request has been received, etc.
If you are writing a web server, favor http.createServer()
over net.createServer()
as it will save you a lot of work. If you are writing some other kind of server, do not use http.createServer()
.