When connection structure is allocated using yw_conn_new(3), you need to use this function in order to connect to the server. You can previously set some connection parameters using yw_set_flag(3). This function creates socket, and tries to connect it to the server. Then it tries to authenticate, and does basic connection feature negotation. Since it's quite complex, it can fail for several reasons. After you're done with this connection, you need to close it, and release YwConnection structure using yw_conn_free(3).
The yw_conn_open() function returns 0 for success or one of the following values in case of error:
YW_ERR_ALREADY_CONNECTED - connection is already active.
YW_ERR_NO_HOME - HOME flag not set, and getenv("HOME") failed.
YW_ERR_NO_AUTH_FILE - authority file hasn't been found. Check errno for details.
YW_ERR_BAD_AUTH_FILE - authority file is invalid. This includes 'host not found' errors.
YW_ERR_SOCKET - socket problem. socket() or connect() call failed.
YW_ERR_PROTO - protocol error.
YW_ERR_VERSION - bad version of peer.
YW_ERR_BAD_AUTH - peer didn't authenticate properly.
YW_ERR_EOF - unexpected EOF reading socket.
YW_ERR_READ - read error.
YW_ERR_WRITE - write error.
YW_ERR_NO_ZLIB - couldn't setup compressed link, this can fail for two reasons. One is that you set "ZLIB" flag to "yes" (instead of "maybe") and local libyw implementaion doesn't support zlib (you can check it, if it supports zlib preprocessor macro YW_HAS_ZLIB is defined), the other is that you set "ZLIB" to "yes" and peer doesn't support zlib compression.
YW_ERR_NO_CRYPT - the other side doesn't support encryption at all (strange).
For more information about determing the way connection is established, please refer to yw_conn_set_flag(3).