+ free freeaddrinfo(*res);
+}
+
+// extern int getnameinfo(struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
+function psi\getnameinfo(string $addr, string &$host = NULL, string &$service = NULL, int $flags = 0) : int {
+ let sa = strval($addr);
+ let salen = strlen($addr);
+ let hostlen = psi\NI_MAXHOST;
+ let host = calloc(hostlen, psi\SIZEOF_CHAR);
+ let servlen = psi\NI_MAXSERV;
+ let serv = calloc(servlen, psi\SIZEOF_CHAR);
+ let flags = intval($flags);
+ return to_int(getnameinfo);
+ set $host = to_string(host);
+ set $service = to_string(serv);
+}