src/irc_net.c
changeset 139 55b9dcc2b73a
parent 138 a716c621cb90
child 140 aa390e52eda8
equal deleted inserted replaced
138:a716c621cb90 139:55b9dcc2b73a
   269 
   269 
   270     // XXX: better error handling
   270     // XXX: better error handling
   271     
   271     
   272     // trap errors
   272     // trap errors
   273     if (conn_err)
   273     if (conn_err)
   274         FATAL_ERROR(conn_err, "async TCP connect failed");
   274         FATAL_ERROR(conn_err, "async connect failed");
   275     
   275     
   276     // ok, yay
   276     // ok, yay
   277     if (irc_net_connected(net, sock, &err))
   277     if (irc_net_connected(net, sock, &err))
   278         FATAL_ERROR(&err, "irc_net_connected failed");
   278         FATAL_ERROR(&err, "irc_net_connected failed");
   279 
   279 
   292     // initialize
   292     // initialize
   293     net->info = *info;
   293     net->info = *info;
   294     TAILQ_INIT(&net->channels);
   294     TAILQ_INIT(&net->channels);
   295     LIST_INIT(&net->users);
   295     LIST_INIT(&net->users);
   296 
   296 
   297     // non-async socket connect?
   297     if (info->raw_sock) {
   298     if (info->raw_sock || info->use_ssl) {
   298         // direct sock_stream connection
   299         // create the socket
   299         log_debug("connected using raw socket: %p", info->raw_sock);
   300         if (info->raw_sock) {
   300 
   301             log_debug("connected using raw socket: %p", info->raw_sock);
   301         sock = info->raw_sock;
   302 
       
   303             sock = info->raw_sock;
       
   304 
       
   305         } else if (info->use_ssl) {
       
   306             log_debug("connecting to [%s]:%s using SSL", info->hostname, info->service);
       
   307 
       
   308             // XXX: over-simplified blocking connect
       
   309             if (sock_ssl_connect(&sock, info->hostname, info->service, err))
       
   310                 goto error;
       
   311         }
       
   312 
   302 
   313         // then create the conn right away
   303         // then create the conn right away
   314         if (irc_net_connected(net, sock, err))
   304         if (irc_net_connected(net, sock, err))
       
   305             goto error;
       
   306 
       
   307     } else if (info->use_ssl) {
       
   308         log_debug("connecting to [%s]:%s using SSL", info->hostname, info->service);
       
   309 
       
   310         if (sock_ssl_connect_async(&sock, info->hostname, info->service, &irc_net_on_connect, net, err))
   315             goto error;
   311             goto error;
   316 
   312 
   317     } else {
   313     } else {
   318         log_debug("connecting to [%s]:%s", info->hostname, info->service);
   314         log_debug("connecting to [%s]:%s", info->hostname, info->service);
   319             
   315