/* Bind to local addresses */
for (i = 0; i < local_ip_count; i++) {
- SILC_LOG_DEBUG(("Binding to local address %s",
- local_ip_addr ? local_ip_addr[i] : ipany));
+ SILC_LOG_DEBUG(("Binding to local address %s:%d",
+ local_ip_addr ? local_ip_addr[i] : ipany, port));
/* Set sockaddr for server */
if (!silc_net_set_sockaddr(&server,
SilcStream stream, void *context)
{
SilcNetConnect conn = context;
+ conn->sop = NULL;
conn->stream_status = status;
conn->stream = stream;
SILC_FSM_CALL_CONTINUE(&conn->fsm);
}
#if defined(ECONNREFUSED)
- if (errno == ECONNREFUSED)
+ if (opt == ECONNREFUSED)
conn->status = SILC_NET_CONNECTION_REFUSED;
#endif /* ECONNREFUSED */
#if defined(ETIMEDOUT)
- if (errno == ETIMEDOUT)
+ if (opt == ETIMEDOUT)
conn->status = SILC_NET_CONNECTION_TIMEOUT;
#endif /* ETIMEDOUT */
#if defined(ENETUNREACH)
- if (errno == ENETUNREACH)
+ if (opt == ENETUNREACH)
conn->status = SILC_NET_HOST_UNREACHABLE;
#endif /* ENETUNREACH */
/** Connecting failed */
- SILC_LOG_DEBUG(("Connecting failed"));
+ SILC_LOG_DEBUG(("Connecting failed, error %s", strerror(opt)));
silc_fsm_next(fsm, silc_net_connect_st_finish);
return SILC_FSM_CONTINUE;
}
/** Connection created */
silc_fsm_next(fsm, silc_net_connect_st_stream);
SILC_FSM_CALL((conn->sop = silc_socket_tcp_stream_create(
- conn->sock, FALSE, FALSE,
- schedule,
+ conn->sock, TRUE, FALSE, schedule,
silc_net_connect_wait_stream, conn)));
}
return SILC_FSM_CONTINUE;
}
- /* Set stream information */
- silc_socket_stream_set_info(conn->stream,
- !silc_net_is_ip(conn->remote) ? conn->remote :
- conn->ip_addr, conn->ip_addr, conn->port);
-
/** Stream created successfully */
SILC_LOG_DEBUG(("Connected successfully, sock %d", conn->sock));
conn->status = SILC_NET_OK;
conn->callback(conn->status, conn->stream, conn->context);
if (conn->op)
silc_async_free(conn->op);
- if (conn->sop)
- silc_async_free(conn->sop);
}
return SILC_FSM_FINISH;
conn->aborted = TRUE;
/* Abort underlaying stream creation too */
- if (conn->sop)
+ if (conn->sop) {
silc_async_abort(conn->sop, NULL, NULL);
+ conn->sop = NULL;
+ }
}
static void silc_net_connect_destructor(SilcFSM fsm, void *fsm_context,