+ /* Add localhost entries */
+ flx_address_parse("127.0.0.1", AF_INET, &a);
+ flx_server_add_address(s, 0, 0, AF_UNSPEC, TRUE, "localhost", &a);
+
+ flx_address_parse("::1", AF_INET6, &a);
+ flx_server_add_address(s, 0, 0, AF_UNSPEC, TRUE, "ip6-localhost", &a);
+}
+
+flxServer *flx_server_new(GMainContext *c) {
+ gchar *hn, *e;
+ flxServer *s;
+
+ static GSourceFuncs source_funcs = {
+ prepare_func,
+ check_func,
+ dispatch_func,
+ NULL,
+ NULL,
+ NULL
+ };
+
+ s = g_new(flxServer, 1);
+
+ s->fd_ipv4 = flx_open_socket_ipv4();
+ s->fd_ipv6 = flx_open_socket_ipv6();
+
+ if (s->fd_ipv6 < 0 && s->fd_ipv4 < 0) {
+ g_critical("Failed to create sockets.\n");
+ g_free(s);
+ return NULL;
+ }
+
+ if (s->fd_ipv4 < 0)
+ g_message("Failed to create IPv4 socket, proceeding in IPv6 only mode");
+ else if (s->fd_ipv6 < 0)
+ g_message("Failed to create IPv6 socket, proceeding in IPv4 only mode");
+
+ if (c)
+ g_main_context_ref(s->context = c);
+ else