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()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…