![]() |
![]() |
![]() |
Initiate connection on a socket
#include <sys/socket.h> int nbaconnect( int s, const struct sockaddr * name, size_t namelen );
libsocket
The nbaconnect() function is called in place of connect(), to prevent a non-blocking connect() from blocking during an autoconnect (see /etc/autoconnect).
When the autoconnect behaviour 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's required. If an autoconnect is required, a file descriptor (fd) is returned. The fd is used to call 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, -1 is returned and nbaconnect() exhibits the same behaviour 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).
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.
accept(), bind(), connect(), errno, fcntl(), getsockname(), nbaconnect_result(), open(), pipe(), read(), select(), socket(), write()
/etc/autoconnect, pipe in the Utilities reference.
![]() |
![]() |
![]() |