- if(listen_socket[listen_sockets].udp < 0) {
- close(listen_socket[listen_sockets].tcp);
- continue;
- }
-
- event_set(&listen_socket[listen_sockets].ev_tcp,
- listen_socket[listen_sockets].tcp,
- EV_READ|EV_PERSIST,
- handle_new_meta_connection, NULL);
- if(event_add(&listen_socket[listen_sockets].ev_tcp, NULL) < 0) {
- logger(LOG_EMERG, _("event_add failed: %s"), strerror(errno));
- abort();
- }
-
- event_set(&listen_socket[listen_sockets].ev_udp,
- listen_socket[listen_sockets].udp,
- EV_READ|EV_PERSIST,
- handle_incoming_vpn_data, NULL);
- if(event_add(&listen_socket[listen_sockets].ev_udp, NULL) < 0) {
- logger(LOG_EMERG, _("event_add failed: %s"), strerror(errno));
- abort();
- }
-
- ifdebug(CONNECTIONS) {
- hostname = sockaddr2hostname((sockaddr_t *) aip->ai_addr);
- logger(LOG_NOTICE, _("Listening on %s"), hostname);
- free(hostname);
- }
-
- memcpy(&listen_socket[listen_sockets].sa, aip->ai_addr, aip->ai_addrlen);
- listen_sockets++;
-
- if(listen_sockets >= MAXSOCKETS) {
- logger(LOG_WARNING, _("Maximum of %d listening sockets reached"), MAXSOCKETS);
- break;
- }
- }
-
- freeaddrinfo(ai);
-
- if(listen_sockets)
- logger(LOG_NOTICE, _("Ready"));
- else {
- logger(LOG_ERR, _("Unable to create any listening socket!"));
- return false;
- }