What is a port?
Port numbers are the means by which an operating system routes incoming packets to the appropriate waiting process. Only one process at a time can listen for incoming packets on a given port. The combination of destination IP address and port uniquely identifies the destination process for a packet. Likewise, the combination of source IP address and port uniquely identifies the source process.
For both TCP and UDP, the port number field of a packet is specified as a 16-bit unsigned integer - this means that valid port numbers range from 1 through 65535. (Port number 0 is reserved and can't be used).
Port numbers 1 through 255 are reserved for well-known services. A well-known service is a service that is widely implemented which resides at a published, "well-known", port. If you connect to port 80 of a host, for instance, you may expect to find an HTTP server. On UNIX machines, ports less than 1024 are privileged and can only be bound by the root user. This is so an arbitrary user on a multi-user system can't impersonate well-known services like TELNET (port 23), creating a security problem. Windows has no such restrictions, but you should program as if it did so that your applications will work cross-platform.