TCP services


There are standard TCP port numbers for common services, i.e.
NamePort
HTTP80
SMTP25
SSH22
FTP data20
FTP control21

A more complete list is in /etc/services.

How do programs set up TCP connections?

Servers:

  1. Use socket(2) to create a socket
  2. Use bind(2) to associate a local IP address and port number with the socket
  3. Use accept(2) to wait for incoming connections
  4. Usually, fork() a child to manage the file handle returned by accept()

Clients:

  1. Use socket(2) to create a socket
  2. Use bind(2) to associate a remote IP address (of the server host) and port number (of the desired service) with the socket
  3. Use connect(2) to initiate the connection (obtaining a file handle)
  4. read() and write() data

UDP sockets are also possible, but don't have guarantees about delivery and sequencing

Next ->


Steve VanDevender
Last modified: Thu Jul 3 12:36:01 PDT 2003