+
+#if HAVE_GETADDRINFO
+ char host[120];
+ struct sockaddr_storage addr;
+ YAZ_SOCKLEN_T len = sizeof(addr);
+
+ if (getpeername(h->iofile, (struct sockaddr *)&addr, &len) < 0)
+ {
+ h->cerrno = CSYSERR;
+ return 0;
+ }
+ if (getnameinfo((struct sockaddr *) &addr, len, host, sizeof(host)-1,
+ 0, 0,
+ (h->flags & CS_FLAGS_NUMERICHOST) ? NI_NUMERICHOST : 0))
+ {
+ r = "unknown";
+ }
+ else
+ r = host;
+
+#else
+
+ struct sockaddr_in addr;
+ YAZ_SOCKLEN_T len = sizeof(addr);