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

to its underlying operations. AF_INET and AF_INET6 sockets are the most widely used application
program interface (API) for communication between processes running on different systems.
AF_UNIX sockets are used for communication between processes running on the same system.
The Guardian version of sockets was implemented for the versions of UNIX systems developed at
the University of California, Berkeley, by the Berkeley Software Distribution (BSD) group. These
sockets are often referred to as “Berkeley sockets” or “BSD sockets.
OSS sockets are based on BSD sockets (the OSS sockets interface is based on BSD 4.3 for AF_INET
and AF_INET6, and BSD 4.3+ for AF_UNIX), but OSS sockets also include limited extensions
based on the X/Open XPG4 specification. The differences between OSS sockets and BSD and
Guardian sockets are discussed in Chapter 11 (page 178).
OSS AF_UNIX Release 2 sockets have improved performance over AF_UNIX Release 1 sockets
because AF_UNIX Release 2 sockets have fewer system processes involved in the delivery of each
message. The following list shows the order of increasing overhead (decreasing performance) for
AF_UNIX Release 2 processes and sockets:
1. Both processes are in the same processor and their sockets were created in that processor.
2. The processes are in different processors and each process is using a socket created in its
processor.
3. One of the processes resides in a processor other than where its socket was created.
4. Both processes reside in processors other than where their socket was created.
OSS AF_UNIX Release 1 sockets and OSS AF_INET and AF_INET6 sockets involve multiple
system processes in the data path for each message, even if both ends of the connection are on
the same processor; as a result, the socket overhead is much higher than for other interprocess
communication mechanisms. The following tradeoffs exist for the use of OSS AF_UNIX Release 1
sockets, AF_INET sockets, and AF_INET6 sockets:
If you must have source compatibility with portability and POSIX standard socket semantics,
use OSS sockets.
If you require improved performance with sockets-like semantics but portability is not a primary
consideration, consider using Guardian sockets. The use of Guardian sockets for NonStop
TCP/IP, Parallel Library TCP/IP, and NonStop TCP/IPV6 is described in the TCP/IP
Programming Manual.
If you require even higher performance and can abandon portability and sockets semantics,
consider changing your program to use $RECEIVE. For more information about programs that
use $RECEIVE, see the Guardian Programmer’s Guide .
If you require maximum performance with portability and can abandon sockets semantics,
use OSS pipes or FIFO files. OSS pipes and FIFOs typically provide a direct data path without
intervening system processes.
Using Message Queues
Messages are classified according to their queueing priority: normal (nonpriority), priority, or high
priority. A message belongs to a particular priority band that determines its ordering when placed
on a queue. Message queues are an optional feature of the XPG4 specifications. HP implements
message queues in the OSS environment with the services of the msgctl(), msgget(),
msgrcv(), and msgsnd() function calls:
msgctl() performs message control operations such as queries, removal of identifiers, and
modifying qualities of message identifiers.
msgget() creates or returns the identifier for a message queue.
msgrcv() reads a message from a queue associated with the msgqid parameter.
msgsnd() sends a message to the queue associated with the msgqid parameter.
90 OSS Porting Considerations