How to Create a Chat Server with Netcat

Netcat is a very powerful network utility for Linux. Netcat was developed in 1995 and has many advanced usages. It featured as one of the Top 100 network security tools of 2006 at rank #4.With netcat, we can perform numerous networking tasks like port scanning, managing connections and setting up servers. One very basic usage of netcat is shown here.

Create a chat server/Client:

Netcat can be used to create a chat server and client. With netcat, we can setup a computer as a chat server and another as a chat client which would connect to that server. This enables chatting between two computers on a network.

To create a chat server, enter this into a terminal:

nc l p port_number'

This will set up a tcp server on the host at the port specified as port_number’. This makes netcat listen to the specified port and relays the incoming message on the terminal with stdout. Connect to the chat server using:

nc server_ip' port_number'c

Now, any connection made to the server on the specified port will set up a chat client through the terminal with stdin.

If you are on a Mac, use only the l switch to create a chat server. So, your command should look like:

nc l port_number'

Connecting to the chat server on a Mac is the same as given above.

  • Share

After Reading This Post Other People Went on to Read: »

Comment Using Facebook

2 Responses to this Article | Share your Opinions/Comments

We moderate comments to prevent spam. Moderation is done within few hours. Please try and stay on topic and refrain from using abusive language. If you think there is a problem with this post, please email the post author or send us an email at tips@techie-buzz.com with the URL and the problem you see and we will rectify it as soon as we can.

  1. Salih on July 25th, 2010 at 6:19 pm #

    Thanks a lot.

    i was trying with nc -l command in linux and it was not working.

    As per the article added -p before the port and it is working fine.

    nc is a wonderful tool

    Regards

    Salih

  2. rdococ on July 27th, 2011 at 2:29 pm #

    Is there one for Windows?