TCP/IP Basics
One of the APIs to the TCP/IP protocol stack available is the socket
API. A socket is a special type of file handle which is used to
transfer data between two parties. The data that is written on one side
of the socket can immediately be read on the other side. The transfer
between the two parties is handled transparently by the underlying TCP/IP.
Various applications have defined high level protocols on this socket
interface for their purposes.
A client needs to follow the following steps to access a server via sockets:
- Create a socket with a call to socket().
- Connect the socket with the server with a call to connect().
- Do iterations of sending and receiving data with calls to send()
and recv().
- Shutdown the connection with a call to shutdown() and close().
A server needs some preparation steps before it can accept clients:
- Create a socket with a call to socket().
- Register the socket with a well-known port address with a call to
bind().
- Create a queue where clients can place connection requests with a call
to listen().
- Accept client request with a call to accept().
The following graphic illustrates this flow:
[
IBM REXX homepage |
Next page |
Tutorial Index |
Object REXX homepage
]
[
IBM homepage |
Order |
Search |
Contact IBM |
Help |
(C) |
(TM)
]
This page is at
http://www2.hursley.ibm.com/rexxtut/socktut2.htm