My client program starts the script that establishes PPP connection in background and continues forward with its own processing. At some point, it calls connect on a non-blocking socket, and also selects the socket for completion of connection before writing. Is there a way for the client program to know if connection got established or not? Does select fail or does it still indicate writablilty if connection fails? Can a timeout be specified on connect?

In some cases, the client program may want to know the reason why the connection could not be established. For eg, if the modem is not connected, if there is no carrier etc. Is there a standard way to catch such errors without blocking the calling process? One workaround is to establish connection in a separate thread. Any other suggestions?