On Monday 17 December 2001 11.38, Raúl Gutiérrez Segalés wrote:
Hi
Are ports only a convention or they define the protocol... I mean that for example when I connect to port 22(ssh) am I passing data in a special way (protocol) or is only that because it is port 22 there is going to be a sshd waiting there and not for example a httpd... Could somebody throw a little more light in this port stuff? :-)
It is a convention. A port is just a number in the TCP header. A program on one machine registers with the TCP stack that when packets come with number X in the port field, it wants them. It is quite possible to start a web server on port 22. It's quite common to start them on high ports to get around firewalls, or if you're on a machine that isn't root. There is a document at http://www.iana.org/assignments/port-numbers that define the standard way to use ports, e.g. ftp on 21, http on 80 etc. You're free to use whatever you want, but if people are to use it you have to tell them what port delivers what service. If you go by the standard, programs can generally handle it automatically. Of course, the program that listens on the port (say sshd for example) will require data to be transmitted according to their own protocol, but that's another matter regards Anders