Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
Porting or Migrating Sockets Applications
Open System Services Porting Guide520573-006
11-6
Differences Between OSS Sockets and Guardian
Sockets
LISTNER cannot directly activate OSS programs. To activate an application in the
OSS environment the same way that LISTNER activates Guardian programs,
either start the application using inetd or write a small program to interface with
the LISTNER process. The latter program would start the real application in the
OSS environment, passing the port number and IP address from LISTNER to the
OSS application. For further information on LISTNER, refer to the TCP/IP
Programming Manual or the IPX/SPX Programming Manual. For more information
on inetd, refer to Starting an OSS Server Process on page 6-26.
The most important difference between OSS sockets and Guardian sockets is the way
in which socket input/output is performed.
When a Guardian sockets application performs waited I/O, control is not returned
to the application until a socket I/O call completes. This behavior is the same as
that of an OSS sockets application using blocking sockets.
If a Guardian sockets application uses nowait I/O for sockets, you must modify it to
use OSS sockets functions.
Guardian concurrent processing uses function calls that are nowait analogs of
standard sockets library calls; these analogous functions include socket_nw(),
recv_nw(), and send_nw(). To perform nowait I/O, a Guardian application:
°
Creates a socket using socket_nw()
°
Performs reads or writes with the other nowait functions (each input/output
operation requires a separate preallocated buffer)
°
Tests Guardian file numbers for I/O completion
You have three choices when migrating a Guardian nowait I/O application to use
OSS sockets:
°
You can rewrite the application to use only blocking sockets. This option is
usually not a good choice for applications that need to handle multiple requests
concurrently. Refer to the requester2 sample program in the Open System
Services Programmers Guide for a blocking sockets application.
°
You can modify the application to use blocking sockets in a nonblocking
manner. An OSS sockets application can perform concurrent operations by:
Testing the OSS sockets file descriptors using the select() function at
certain points during processing for their readiness for read or write
operations
Performing reads or writes on any OSS sockets that are ready
Refer to the server2 sample program in the Open System Services
Programmers Guide for an application that uses blocking sockets in a
nonblocking manner.
°
You can modify the application to use nonblocking sockets. An OSS sockets
application can perform concurrent operations by: