[Previous] [Contents] [Next]

nbaconnect()

Initiate connection on a socket

Synopsis:

#include <sys/socket.h>

int nbaconnect( int s, 
                const struct sockaddr * name,
                size_t namelen );

Library:

libsocket

Description:

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.


Note: 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).

Returns:

fd
A file descriptor. It's used with nbaconnect_result() to get the result of the nbaconnect() attempt.
-1
An error occurred (errno is set).

Errors:

Any value from the Errors section in connect(), as well as:

EINVAL
The socket file descriptor being passed isn't non-blocking.

Classification:

QNX 6

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

Caveats:

The pipe manager must be available.

See also:

accept(), bind(), connect(), errno, fcntl(), getsockname(), nbaconnect_result(), open(), pipe(), read(), select(), socket(), write()

/etc/autoconnect, pipe in the Utilities reference.


[Previous] [Contents] [Next]