-void handle_meta_connection_error(struct bufferevent *event, short what, void *data) {
- connection_t *c = data;
- logger(LOG_EMERG, _("handle_meta_connection_error() called: %d: %s"), what, strerror(errno));
- terminate_connection(c, c->status.active);
+#endif
+
+ bind_to_address(mesh, c);
+
+ /* Connect */
+
+ if(!mesh->proxytype) {
+ result = connect(c->socket, &c->address.sa, SALEN(c->address.sa));
+ } else {
+ result = connect(c->socket, proxyai->ai_addr, proxyai->ai_addrlen);
+ freeaddrinfo(proxyai);
+ }
+
+ if(result == -1 && !sockinprogress(sockerrno)) {
+ logger(mesh, MESHLINK_ERROR, "Could not connect to %s: %s", outgoing->name, sockstrerror(sockerrno));
+ free_connection(c);
+
+ goto begin;
+ }
+
+ /* Now that there is a working socket, fill in the rest and register this connection. */
+
+ c->status.connecting = true;
+ c->name = xstrdup(outgoing->name);
+ c->outcompression = mesh->self->connection->outcompression;
+ c->last_ping_time = mesh->loop.now.tv_sec;
+
+ connection_add(mesh, c);
+
+ io_add(&mesh->loop, &c->io, handle_meta_io, c, c->socket, IO_READ | IO_WRITE);
+
+ return true;