nodejs - net or http module

北慕城南 提交于 2019-12-20 00:07:27

问题


I'm doing chat system with nodejs. To create a node server I can either use net or http module. So what is the difference and benefit of using each of them ?


回答1:


http is built on top of net (which handles the TCP layer underlying HTTP).

I imagine that your "chat system" will have browser-based clients, since node.js isn't great for GUIs/desktop apps at the moment. If that's the case, you'll most likely want to use http.

A node.js chat server has already been made - node-chat. You could build yours on top of this, or take a look at its source code for some ideas.



来源:https://stackoverflow.com/questions/5739028/nodejs-net-or-http-module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!