Check out a free preview of the full Networking and Streams course

The "Netcat" Lesson is part of the full, Networking and Streams course featured in this preview video. Here's what you'd learn in this lesson:

Netcat (often abbreviated to nc) is a computer networking utility for reading from and writing to network connections using TCP or UDP.


Transcript from the "Netcat" Lesson

>> If you don't already have Netcat, go ahead and try to figure out how to install it, you can, if you ran the nclp command or you might have to do Netcat l or p. Sometimes the options are a little mixed up. So you might have to do something like dash l without the p, Cuz there's like a couple of different versions.

There's like a BSD version and another one. So, anyways figure out how to run Netcat, and Netcat is really nice because it lets you have a plain text session with a server or you can be the server and you can just type in responses. So here's a fun thing to try, hang on, so here's some different things you can try.

Probably one of those is gonna work, the top one or the second one down. This will listen for an incoming connection on port 5000. And then the third one down, the nc localhost 5000, if you do that in another terminal window, you should be able to connect to your server and you can type a message.

So I'm gonna go ahead and do that over here on the right. So I'm gonna do nc dash lp is, it's how it works in my system. I could do nc localhost 5000. Now on either side, I can type whatever I want, so I can type, hello, I am the client.

And over here on the server, I can type, hello clients, I am the server. And so pretty much, we have a little chat program-
>> [COUGH]
>> Going on here. This is more or less how protocols and servers and clients work. Although, if you have a protocol, the way that you exchange information is a lot more nailed down, so it's not so freeform as this.

For example, if you had something like, maybe you have a convention where you use brackets to say the username. But then there's no way of enforcing, like which side, so the server could lie about being the client and the client could lie about being the server. You can also have multiple clients connected.

So if I open a third connection now as a client to my server. In this case with Netcat, you can only have one connection. But if you have a server with node for example, then you can have as many clients as you like, up to like, whatever your system can handle, like probably, maybe like 5 to 10,000 to expect till you run out of file descriptors.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now