doc/designs/ddd/ddd-06-mem-uv.c
/*
 * The application wants to create a new outgoing connection using a given
 * SSL_CTX. An outgoing TCP connection is started and the callback is called
 * asynchronously when the TLS handshake is complete.
 *
 * hostname is a string like "openssl.org" used for certificate validation.
 */
The application wants to create a new outgoing connection using a given
SSL_CTX. An outgoing TCP connection is started and the callback is called
asynchronously when the TLS handshake is complete.

hostname is a string like "openssl.org" used for certificate validation.
The application wants to create a new outgoing connection using a given SSL_CTX . An outgoing TCP connection is started and the callback is called asynchronously when the TLS handshake is complete . hostname is a string like " openssl . org " used for certificate validation .
APP_CONN *new_conn(SSL_CTX *ctx, const char *hostname,
                   struct sockaddr *sa, socklen_t sa_len,
                   app_connect_cb *cb, void *arg)
{
    int rc;
    APP_CONN *conn = NULL;
    conn = calloc(1, sizeof(APP_CONN));
    if (!conn)
        return NULL;
    uv_tcp_init(uv_default_loop(), &conn->tcp);
    conn->tcp.data = conn;
    conn->stream            = (uv_stream_t *)&conn->tcp;
    conn->app_connect_cb    = cb;
    conn->app_connect_arg   = arg;
    conn->tcp_connect.data  = conn;
    rc = uv_tcp_connect(&conn->tcp_connect, &conn->tcp, sa, tcp_connect_done);
    if (rc < 0) {
        uv_close((uv_handle_t *)&conn->tcp, net_connect_fail_close_done);
        return NULL;
    }
    conn->ctx       = ctx;
    conn->hostname  = hostname;
    return conn;
}
APP_CONN * new_conn ( SSL_CTX * ctx , const char * hostname , struct sockaddr * sa , socklen_t sa_len , app_connect_cb * cb , void * arg ) { int rc ; APP_CONN * conn = NULL ; conn = calloc ( 1 , sizeof ( APP_CONN ) ) ; if ( ! conn ) return NULL ; uv_tcp_init ( uv_default_loop ( ) , & conn -> tcp ) ; conn -> tcp . data = conn ; conn -> stream = ( uv_stream_t * ) & conn -> tcp ; conn -> app_connect_cb = cb ; conn -> app_connect_arg = arg ; conn -> tcp_connect . data = conn ; rc = uv_tcp_connect ( & conn -> tcp_connect , & conn -> tcp , sa , tcp_connect_done ) ; if ( rc < 0 ) { uv_close ( ( uv_handle_t * ) & conn -> tcp , net_connect_fail_close_done ) ; return NULL ; } conn -> ctx = ctx ; conn -> hostname = hostname ; return conn ; }
The application wants to create a new outgoing connection using a given
 SSL_CTX.
The application wants to create a new outgoing connection using a given SSL_CTX .