struct addrinfo hints;
struct addrinfo *addrinfo = NULL;
int error;
+ socklen_t size;
gboolean connect_finished = TRUE;
g_assert(s != NULL);
ioc = g_io_channel_unix_new(sock);
g_io_channel_set_flags(ioc, G_IO_FLAG_NONBLOCK, NULL);
+
if (connect(sock, res->ai_addr, res->ai_addrlen) < 0) {
if (errno == EINPROGRESS) {
connect_finished = FALSE;
break;
}
+ size = sizeof(struct sockaddr_storage);
+ g_assert(s->connection.data.tcp.local_name == NULL);
+ g_assert(s->connection.data.tcp.remote_name == NULL);
+ s->connection.data.tcp.remote_name = g_memdup(res->ai_addr,
+ res->ai_addrlen);
+ s->connection.data.tcp.namelen = getsockname(sock, s->connection.data.tcp.local_name, &size);
+
freeaddrinfo(addrinfo);
if (!ioc) {
void *data)
{
struct network *s = data;
- socklen_t size;
- int sock = g_io_channel_unix_get_fd(ioc);
struct tcp_server_config *cs;
if (cond & G_IO_ERR) {
if (cond & G_IO_OUT) {
s->connection.state = NETWORK_CONNECTION_STATE_CONNECTED;
- size = sizeof(struct sockaddr_storage);
- g_assert(s->connection.data.tcp.local_name == NULL);
- g_assert(s->connection.data.tcp.remote_name == NULL);
- s->connection.data.tcp.remote_name = g_malloc(size);
- s->connection.data.tcp.local_name = g_malloc(size);
- s->connection.data.tcp.namelen = getsockname(sock, s->connection.data.tcp.local_name, &size);
- getpeername(sock, s->connection.data.tcp.remote_name, &size);
-
cs = s->connection.data.tcp.current_server;
if (cs->ssl) {
#ifdef HAVE_GNUTLS