From the man page:
If the connection or binding succeeds, zero is returned. On error, -1 is returned, and errno is set appropriately.
The following are general socket errors only. There may be other domain-specific error codes.
EACCES For UNIX domain sockets, which are identified by pathname: Write permission is denied on the socket file, or
search permission is denied for one of the directories in the path prefix. (See also path_resolution(7).)
The user tried to connect to a broadcast address without having the socket broadcast flag enabled or the connec‐
tion request failed because of a local firewall rule.
Local address is already in use.
... etc ...
So you know that the call to
connect() did not succeed, because it returned -1. There's a lot of reasons that
connect() might fail, and you can examine
errno to find out why. In many cases, depending on context, an unsuccessful connect might be expected, or recoverable (e.g. if you've run out of resources, you might be able to either wait for other connections to close, or be able to clean up/close old connections). In your case errno is EINPROGRESS "The socket is nonblocking and the connection cannot be completed immediately". See the man page for further information. If this is a bluetooth, then consult any relevant bluetooth docs to see if EINPROGRESS is mentioned and why you might get that error code.
perror() will always print "operation now in progress" any time errno == EINPROGRESS. Some library calls might set EINPROGRESS to indicate a condition that does not directly translate to "operation now in progress", but the resource is temporarily busy, and you should try again later, and EAGAIN already is used for some other retry condition.