Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (s and S) spt_connectx(2)
• A connection is established.
• A timeout occurs.
• A signal is caught.
If a timeout occurs, the spt_connectx() call fails and errno is set to [ETIMEDOUT]; the connec-
tion is aborted.
If an spt_connectx() call is interrupted by a signal that is caught while the call is blocked wait-
ing to establish a connection, the spt_connectx() call fails and sets errno to [EINTR]; the con-
nection is not aborted and is later established asynchronously.
When a connection cannot be created immediately and O_NONBLOCK is set for the file
descriptor of the socket, the spt_connectx() call fails and sets errno to [EINPROGRESS]; the
connection is not aborted and is later established asynchronously. Subsequent calls to the
spt_connectx() function for the same socket before the connection is completed will fail and set
errno to [EALREADY].
NOTES
The macro to map connect() to spt_connectx() is available in C applications when
SPT_THREAD_AWARE_NONBLOCK has been defined in the following manner before
including spthread.h:
#define SPT_THREAD_AWARE_NONBLOCK
The alias to link connect() to spt_connectx() is available in C++ applications when
SPT_THREAD_AWARE_PRAGMA_NONBLOCK has been defined in the following manner
before including spthread.h:
#define SPT_THREAD_AWARE_PRAGMA_NONBLOCK
To use this function in a threaded application that uses the Standard POSIX Threads library on
systems running J06.10 or later RVUs or H06.21 or later RVUs, you must perform all of the fol-
lowing tasks:
• Include the spthread.h header file in the application.
• Compile the application using the _SPT_MODEL_ feature test macro or equivalent
compiler command option in addition to any other feature test macros in use.
• Link the application to the zsptdll library (/G/system/zdllnnn/zsptdll).
When an asynchronous connection is complete, a call to the select() function indicates that the
file descriptor for the socket is ready for writing.
RETURN VALUES
Upon successful completion, the spt_connectx() function returns the value 0 (zero). Otherwise,
the value -1 is returned and errno is set to indicate the error.
If the socket becomes invalid (is closed by another thread), -1 is returned with an errno value of
[EBADF]. If a signal is received via the pthread_kill() function and is not blocked, ignored, or
handled, -1 is returned with an errno value of [EINTR].
ERRORS
If any of these conditions occur, the spt_connectx() function sets errno to the corresponding
value:
[EACCES] The socket is in the AF_UNIX domain and either search permission is denied for
a component of the pathname in the sockaddr structure, or write access to the
specified socket is denied.
527186-023 Hewlett-Packard Company 7−147