Practical Computing Advice and Tutorials

Tue: 09 Aug 2022

Site Content


Technical Knowhow

Command Line Interface


LAN Message Project

My understanding is that one of the driving forces behind having computers connected together, or 'networked' was so that machines could be remotely updated, rather than having a person physically doing the process on-site. One of the early realisations about networked computers was not the fact that computers could 'talk' to each other, but that humans could, so, when messaging systems were set-up, as a kind of a ad hoc addition, just because it could be done, messages very soon dominated the network traffic.

To demonstrate just how easy it is for two or more people to have a 'live chat' session over LAN connected computers, I've written this little project. Some network administrators see 'Ncat' as a security risk and as such DO NOT allow it on any connected computers.

>X<                  Please read this notice and acknowledge that you understand the risks by clicking the X

Do Not Use This On A LAN That Is Not Yours.

If you try this on a LAN in your office, you could be contravening your terms of employment.

You are responsible for your actions, not me.


Email is quick and easy to use, so this project while, a bit of fun, is in no way a substitute, but it does demonstrate one of the early ways in which computer users could send text messages back and forth, which at the time, was a completely new way to communicate with another person.

I'll be using 'Ncat' which is quite a powerful networking utility and can be used for much more than this simple 'toy'. It's described as A Swiss Army Knife Utility to write and read data across TCP and UDP network connections. and was written in C.

Ncat is a modern reinvention of the venerable Netcat (nc) tool released by Hobbit in 1996.
While Ncat is similar to Netcat in spirit, they do not share any source code. Instead, Ncat makes use of Nmap's well optimised and tested networking libraries.

In its most basic form, Ncat simply moves bits from one place to another. This is all that is needed to set up a simple chat system. By default, Ncat reads from standard input and writes to standard output, meaning that it will send whatever is typed at the keyboard and will show on the screen whatever is received.

Compatibility with the original Netcat and some well known variants is maintained where it doesn't conflict with Ncat's enhancements or cause usability problems. Ncat adds many capabilities not found in Hobbit's original nc, including SSL support, proxy connections, IPv6, and connection brokering. The original nc contained a simple port scanner, but this has been omitted from Ncat because a preferred tool for that function exist.

Ncat operates in one of two basic modes: connect mode and listen mode.

The ncat command may simply be nc on some systems. You'll need to find out by trying the command from a CLI. On a Windows machine, use a search to find the .exe file and copy it (don't move it) to a location for this project, something like a temp/chat/ folder in your home directory.

So, on my windows machine my CLI prompt is showing...


... and if I type dir I can see nc.exe

My Linux Box CLI prompt is showing...

:~/temp/chat $

If I enter the command nc on either CLI I can see that Ncat runs, but stops and gives me a complaint about usage. If your Linux box prompt changes to...

Cmd line:

... just press Ctrl|c to exit.

Now we'll need the IP Addresses for each machine. Use the command ipconfig on Windows and ifconfig on Linux.

I have on Windows, and on Linux

Now, to open a TCP connection...

One machine will have to 'listen' for a connection from the other. I'm going to have the Windows machine do the 'listening' which will required the machine to open a port through my Personal Firewall. This will be a good test for my Firewall as I should get a warning about such activity. The command is...

nc -l 9000

... and indeed, my Firewall did its job and warned me what nc.exe was about to do.

On my Linux machine I can now connect to my Windows machine with...

nc 9000

A point-to-point connection is up and I can 'chat' between the two machines.

Pressing Ctrl|c on either machine will terminate the connection.

So, what I did there was, on machine, tell 'nc' to open a TCP connection on port 9000 and 'listen' for any connections. On the other machine I told 'nc' to go and look for a TCP connection at the IP Address on port 9000. 'nc' on the one machine was then able to send and receive the data from 'nc' on the other machine.

This idea can be extended so that you can have three or more machine participate, in a 'chat room', if you like, with an option called "Connection Brokering".

Now that we've got the connection side sorted, we can have a little more fun!

On your Linux CLI, type...

nano index.htm

This will open the nano text editor. Now C & P this html into the index.htm file, then press Ctrl|x then y, and then press Enter.

<!DOCTYPE html>
        <title>Netcat: The TCP/IP Swiss Army Knife</title>
        <h2>Welcome to my HTTP Server!</h2>

**Tip: Ctrl|c to copy: you can paste with a R-Click of the mouse.

Now type...

sudo nc -l -p 80 < index.htm

Now, on another machine, open a Web Browser and in the address bar type in the IP Address of your Linux Box. E.g.

Voila! A one-shot web server!

[The full page can been viewed here: http://nc110.sourceforge.net/]

My thanks to the author of this excellent tool!