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.

Get Unlimited Access Now

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.

[00:00:21] 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.

[00:00:49] 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.

[00:01:09] 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.

[00:01:29] 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.

[00:02:04] 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.

[00:02:22] 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.