Initiate a connection on a socket (nonblocking)
#include <sys/socket.h> int nbaconnect( int s, const struct sockaddr * name, size_t namelen );
Use the -l socket option to qcc to link against this library.
The nbaconnect() function is called in place of connect(), to prevent a nonblocking connect() from blocking during an autoconnect (see /etc/autoconnect).
When the autoconnect behavior is used, connect() may block your application while waiting for the autoconnect to complete; nbaconnect() allows your application to continue executing during the autoconnect.
The nbaconnect() function takes the same arguments as connect(), but it differs in the return value when an autoconnect is required. If an autoconnect is required, a file descriptor (fd) is returned. The fd is used in the call to nbaconnect_result() to get the errno related to the autoconnect and the connect attempt.
|Since nbaconnect_result() is a blocking call, it's recommended that you call select() first to determine if there's data available on the pipe.|
When the data's available, call nbaconnect_result() to get the status of the nbaconnect() attempt.
If an autoconnect isn't required, nbaconnect() returns -1 and exhibits the same behavior as connect() on nonblocking sockets (e.g. if -1 is returned and errno is set to EINPROGRESS, it's possible to do a select() for completion by selecting the socket for writing).
A file descriptor that you can pass to nbaconnect_result() to get the result of the nbaconnect() attempt, or -1 if an error occurred (errno is set).
Any value from the Errors section in connect(), as well as:
The pipe manager must be available.
accept(), bind(), connect(), errno, fcntl(), getsockname(), nbaconnect_result(), open(), pipe(), read(), select(), socket(), write()
/etc/autoconnect, pipe in the Utilities Reference.