asynchronous - http.createserver vs net.createserver in node.js -


i having trouble understanding difference between net.createserver , http.createserver in node.js.

i have read documentation both methods located @ these 2 urls https://nodejs.org/api/net.html#/net_net,https://nodejs.org/api/http.html#/http_class_http_server.

i understand http.createserver creates http server, documentation says net.createserver creates tcp server. understand tcp transmission protocol http on top of , http servers set read http request headers. understand concept of emitters in node.js pretty well. dont understand notion of tcp server , why 1 made in node.js. context coding chat application example in "node.js in action" book.

thanks help

http.createserver() sets server handles http protocol, indeed transmitted on tcp. net.createserver() creates server understands when tcp connection has happened, , data has been transmitted, , on, doesn't know whether valid http request has been received, etc.

if writing web server, favor http.createserver() on net.createserver() save lot of work. if writing other kind of server, not use http.createserver().


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -