+ con->link = link;
+ con->state = Conn_Connecting;
+ con->iochan = iochan_create(cs_fileno(link), connection_handler, 0);
+ iochan_setdata(con->iochan, con);
+ pazpar2_add_channel(con->iochan);
+
+ /* this fragment is bad DRY: from client_prep_connection */
+ cl->state = Client_Connecting;
+ iochan_setflag(con->iochan, EVENT_OUTPUT);
+ return 0;
+}
+
+void connect_resolver_host(struct host *host)
+{
+ struct connection *con = host->connections;
+
+ while (con)
+ {
+ if (con->state == Conn_Resolving)
+ {
+ if (!host->ipport) /* unresolved */
+ {
+ connection_destroy(con);
+ /* start all over .. at some point it will be NULL */
+ con = host->connections;
+ }
+ else if (!con->client)
+ {
+ yaz_log(YLOG_WARN, "connect_unresolved_host : ophan client");
+ connection_destroy(con);
+ /* start all over .. at some point it will be NULL */
+ con = host->connections;
+ }
+ else
+ {
+ connection_connect(con);
+ con = con->next;
+ }
+ }
+ }
+}
+
+
+// Creates a new connection for client, associated with the host of
+// client's database
+static struct connection *connection_create(struct client *cl)
+{
+ struct connection *new;
+ struct host *host = cl->database->database->host;