Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)

Refer to the requester2 sample program in the Open System Services Programmer’s
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
Programmer’s 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:
Marking existing sockets as nonblocking using the fcntl() function
Performing reads or writes on any sockets that are ready
Handling the errno value EWOULDBLOCK and retrying the input or output later
when necessary
Table 13 summarizes the differences between nonblocking (OSS) and nowait
(Guardian) sockets I/O.
Table 13 Major Differences Between OSS and Guardian Sockets Input/Output
Guardian Nowait I/OOSS Nonblocking I/O
A socket is created as waited with socket()
or as a nowait socket with socket_nw().
A socket is created with socket() and
fcntl(fd, F_SETFL,O_NONBLOCK) makes
the socket nonblocking.
When a socket I/O call is made, control is
returned immediately to the application. The
When a socket I/O call is made, control is
returned immediately to the application. Either
operation is performed concurrently with thethe operation is performed or the error
EWOULDBLOCK is returned. application execution. The status of the I/O
completion must be checked with a Guardian
procedure call.
Every socket operation requires a separate
preallocated buffer. For example, four recv()
calls require four buffers.
A socket operation requires a single buffer. For
example, four recv() calls require one buffer.
AWAITIOX operates on file numbers rather than
file descriptors. FILE_COMPLETE_ allows
The select() function waits for specified file
descriptors for the next opportunity to issue a
nonblocking I/O call.
waiting for completion on file numbers and on
the readiness of file descriptors;
FILE_COMPLETE_ therefore acts like a
combination of AWAITIOX and select().
Compiling Native and TNS OSS Programs
To compile native OSS applications, you must use the TNS/R or TNS/E native mode c89 utility
or the c99 utility. The following OSS shell command compiles and links the native sockets program
nsock.c:
c89 -o nsock nsock.c -l c -D _XOPEN_SOURCE_EXTENDED = 1
-D _TANDEM_SOURCE
To compile G-series TNS OSS applications, you must use the TNS c89 compiler. TNS AF_INET
sockets applications must be linked with the shared sockets library libinet.a, which resides in
/usr/lib. The following OSS shell command compiles the TNS sockets program nnsock.c:
Porting Guardian Sockets Applications to the OSS Environment 183