IPX/SPX Programming Manual
Library Routines
HP NonStop IPX/SPX Programming Manual—528022-001
5-4
Syntax and Semantics of Socket Library Routines
Syntax and Semantics of Socket Library
Routines
This subsection describes each routine in the socket library. The routines are listed
alphabetically. Each description includes the following information:
•
What the routine does
•
What headers you need to specify in an #include statement within your
programs before calling the routine
•
What arguments the routine accepts and how it interprets them
•
What value the routine returns and how you should interpret it
•
What types you must declare for each argument and for the return value
•
What errors can be returned
•
What guidelines you need to consider when using the routine
Many of the descriptions include an example that shows how to use the routine. The
sample programs in Section 6, Sample Programs also provide examples of calling the
routines.
For a summary of the C header files provided with the socket library and for
descriptions of the data structures provided in the header files, see Section 4, Data
Structures.
All return codes and values are of type integer unless otherwise noted.
Nowait Routines
Most of the socket routines have two versions: one for waited operations and another
for nowait operations. The names of the nowait routines end in the suffix _nw. Except
for the socket_nw routine, the nowait routines include an additional tag parameter
that is passed to the NonStop Kernel file-system procedures.
Error Conditions
Most routines that refer to a socket number (socket), plus a few support routines,
indicate an error condition by returning an otherwise impossible return value (usually
-1) and placing the appropriate error number in the external variable errno. Because
errno is not cleared on successive calls, you should test it only after an error has
occurred. You can call the perror function to print the text message associated with the
current error to the standard C error file (the file named stderr).
The text message description of each routine lists most error numbers that can be
returned in errno on a call to the particular routine. A complete list of socket errors
and their meanings is given in Appendix B, Socket Errors. Note that you must interpret