TCP services
There are standard TCP port numbers for common services, i.e.
Name | Port
| HTTP | 80
|
SMTP | 25
|
SSH | 22
|
FTP data | 20
|
FTP control | 21
|
A more complete list is in /etc/services.
How do programs set up TCP connections?
Servers:
- Use socket(2) to create a socket
- Use bind(2) to associate a local IP address and port
number with the socket
- Use accept(2) to wait for incoming connections
- Usually, fork() a child to manage the file handle
returned by accept()
Clients:
- Use socket(2) to create a socket
- Use bind(2) to associate a remote IP address (of the
server host) and port number (of the desired service) with the socket
- Use connect(2) to initiate the connection (obtaining a
file handle)
- 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