z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


The REXX-EXEC RSSERVER sample program for IPv4

z/OS Communications Server: IP Sockets Application Programming Interface Guide and Reference
SC27-3660-00

The server sample program shows an example of how to use sockets in nonblocking mode. The program waits for connect requests from client programs, accepts the requests, and then sends the data. The sample can handle multiple client requests in parallel processing.

The server program sets up a socket to accept connection requests from clients and then waits in a loop for events reported by the SELECT command. If a socket event occurs, it is processed. A read event can occur on the original socket for accepting connection requests and on sockets for accepted socket requests. A write event can occur only on sockets for accepted socket requests.

A read event on the original socket for connection requests means that a connection request from a client occurred. Read events on other sockets indicate that there is either data to receive or that the client has closed the socket. Write events indicate that the server can send more data. The server program sends only one line of data in response to a write event.

The server program keeps a list of sockets to which it wants to write. It keeps this list to avoid unwanted socket events. The TCP/IP protocol is not designed for one single-threaded program communicating on many different sockets, but for multithread applications where one thread processes only the events that originate from a single socket.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014