Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nodejs - net or http module

Tags:

http

node.js

chat

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 ?

like image 395
angry kiwi Avatar asked Apr 21 '11 03:04

angry kiwi


1 Answers

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.

like image 119
David Tang Avatar answered Nov 13 '22 09:11

David Tang