The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Using the Node.js net module to create a tcp server

Using the Node.js net module to create a tcp server

3:54
In this lesson, you'll learn how to include the built-in node.js 'net' module in your application and create a tcp server. You will learn about the different event listeners used, how to specify specific ports and addresses for your server, and identify where each section of your code is used in the server lifecycle.
Watch this lesson now
Avatar
egghead.io

In this lesson, you'll learn how to include the built-in node.js 'net' module in your application and create a tcp server. You will learn about the different event listeners used, how to specify specific ports and addresses for your server, and identify where each section of your code is used in the server lifecycle.

Avatar
Dean

I know this has been out a long time, already - but I am going over it again and as with some of these course (not just node etc..), there is no mention when using this lesson would be appropriate. For instance, as someone who is learning to write a TCP server. When would I use it over a http server? What is the benefit / usage of using a TCP server?

In reply to egghead.io
Avatar
Will

Hey Dean,
Thanks for your comment!
An http server is specific to the type of data being passed over the TCP port: http. It uses TCP underneath. If you are serving up web traffic, use the http module so you don't have to re-invent that work yourself. You would use the TCP module in scenarios where you want to deal with the raw TCP data yourself- for instance, creating your own messaging platform over TCP. Other examples of non-http data sent over TCP include email(SMTP over port 25), ftp (on port 21), or IRC (on port 194 or 6667).
Hope this helps!
If not, please let me know!

In reply to Dean
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?