Linux Basics

61 / 87
   

Networking: Sockets and ports

There are some programs such as a web server that need to keep running all the time. Such programs are called services.

You can communicate with such programs even from another computer. These programs or processes bind themselves to a port. In other words, such programs listen on a port. No two programs can listen on the same port. Every computer is a given an IP address which is unique in the network so that other computers or users on other computers can connect to such systems.

For example, a web server listens on 80 port and an email server listens on 25 port.

You can connect and talk to any service using nc command in the following way:

    nc computer_name(or ip_address) port_number

The way a person refers to himself as "I", a computer refers itself as localhost or IP Address 127.0.0.1. it is also called as a loopback address.