TCP Ports and Sockets

Three identification numbers are commonly used when referring to TCP sockets.

Note

TCP ports are known by a variety of names. These names include TCP port number, TCP port address, TCP port, port number, port address, port, and data port.

Any application or process that uses TCP for its transport is assigned a unique identification number called a TCP port. TCP ports specify the path of communication between client and server applications. These ports are numbered beginning with zero. Port numbers for client applications are dynamically assigned by the operating system when there is a request for service. Port numbers for server applications are preassigned by the Internet Assigned Numbers Authority (IANA) and do not change.

IANA is the group that assigns processes to port numbers 0 through 1023. This range of numbers is reserved for services. A client application or process that uses TCP as a transport is assigned a port number greater than 1023 by the operating system.

A server application or process that uses TCP as a transport has at least one preassigned port number. For example, the preassigned port numbers for FTP server services are 20 (data) and 21 (control). These port assignments are called the "Well Known Port Numbers" and are documented in RFC 1700 (see http://ds.internic.net/std/std2.txt). Table 1.7 is a short list of some Well Known Port Numbers. (For more port numbers, see Appendix B, "Port Reference for Microsoft TCP/IP," in the Windows NT Server Networking Guide.)

Table 1.7 Some Well Known Port Numbers

Port number

Process name

Description

1

TCPMUX

TCP Port Service Multiplexer

5

RJE

Remote Job Entry

20

FTP-DATA

File Transfer Protocol - Data

21

FTP

File Transfer Protocol - Control

23

TELNET

Telnet

25

SMTP

Simple Mail Transfer Protocol

42

NAMESERV

Host Name Server

49

LOGIN

Login Host Protocol

53

DOMAIN

Domain Name System

69

TFTP

Trivial File Transfer Protocol

70

GOPHER

Gopher

80

HTTP

HTTP

103

X400

X.400

110

POP3

Post Office Protocol version 3

137

NETBIOS-NS

NetBIOS Name Service

139

NETBIOS-DG

NetBIOS Datagram Service

150

NETBIOS-SS

NetBIOS Session Service

156

SQLSRV

SQL Server

179

BGP

Border Gateway Protocol


Port numbers are used in conjunction with an IP address to form a socket. Sockets always have a number (or address) associated with them and designate an endpoint. Examples of socket numbers are shown in Table 1.8.

Table 1.8 Socket Examples

IP address

Port number

Socket number

10.155.22.99

1028

#10.155.22.99(1028)

172.16.16.10

21

#172.16.16.10(21)