Ports and Sockets Explained

On a TCP/IP network, data travels from a port on the sending computer to a port on the receiving computer. A port is an address that identifies the application associated with the data. The source port number identifies the application that sent the data, and the destination port number identifies the application that receives the data. Each port is assigned a unique 16-bit number in the range of 0 through 65535. Additionally, there are two types of ports, TCP and UDP, that are based on their respective protocols.

Today, the very existence of ports and their numbers is more or less transparent to the users of the network, as many ports are standardized. Thus, a remote computer will know which port it should connect to for a specific service. For example, all servers that offer Telnet services do so on TCP port 23, and web servers normally run on TCP port 80. This means that when you dial up the Internet to connect to a web server via the Internet, you automatically connect to port 80, and when you use Telnet, you automatically connect to port 23. The TCP/IP protocol uses a modifiable lookup table to determine the correct port for the data type. Table 3.1 lists some of the well-known port numbers for common protocols.

Table 3.1: Well-Known Port Numbers for Common Protocols

Port

Protocol

UDP port 15

NETSTAT

TCP port 21

FTP

TCP port 23

Telnet

TCP port 25

SMTP

UDP port 53

DNS

UDP port 69

TFTP

TCP port 70

Gopher

TCP port 79

Finger

TCP/UDP port 80

HTTP

TCP port 110

POP3

UDP port 111

RPC

TCP port 119

NNTP (Network News Transfer Protocol)

TCP port 123

NTP

UDP port 137

NetBIOS name service

UDP port 161

SNMP network monitor

UDP port 2049

NFS

In multiuser systems, a program can define a port on the fly if more than one user requires access to the same service at the same time. Such a port is known as a dynamically allocated port and is assigned only when needed— for example, when two remote computers dial into a third computer and simultaneously request Telnet services on that system.

The combination of an IP address (more on IP addresses in a moment) and a port number is known as a socket. A socket identifies a single network process in terms of the entire Internet. Two sockets—one on the sending system and one on the receiving host—are needed to define a connection for connection-oriented protocols, such as TCP. You may hear or see the terms socket and port used as if they are interchangeable terms, but they are not.

Note 

In the Novell NetWare world, a socket is part of an IPX internetwork address and acts as a destination for the IPX data packet. Most socket numbers are allocated dynamically, but a few are associated with specific functions.

Sockets were first developed as a part of the BSD Unix system kernel, in which they allow processes that are not running at the same time or on the same system to exchange information. You can read data from or write data to a socket just as you can do with a file. Socket pairs are bidirectional so that either process can send data to the other.




Network+ Study Guide
Network+ Study Guide
ISBN: 470427477
EAN: N/A
Year: 2002
Pages: 151

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net