+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "setsockopt SO_REUSEADDR %s:%s",
+ server->host, server->port);
+ freeaddrinfo(ai);
+ CLOSESOCKET(s);
+ return 1;
+ }
+ if (bind(s, ai->ai_addr, ai->ai_addrlen) < 0)
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "bind %s:%s",
+ server->host, server->port);
+ freeaddrinfo(ai);
+ CLOSESOCKET(s);
+ return 1;
+ }
+ freeaddrinfo(ai);
+ if (listen(s, SOMAXCONN) < 0)
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "listen %s:%s",
+ server->host, server->port);
+ CLOSESOCKET(s);
+ return 1;
+ }
+
+ if (record_fname)
+ {
+ record_file = fopen(record_fname, "wb");
+ if (!record_file)
+ {
+ yaz_log(YLOG_FATAL|YLOG_ERRNO, "fopen %s", record_fname);
+ CLOSESOCKET(s);
+ return 1;
+ }