Initiate a connection on a socket (nonblocking)
#include <sys/socket.h> int nbaconnect( int s, const struct sockaddr * name, size_t namelen );
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.
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:
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
The pipe manager must be available.