 
 import CoreFoundation
 
+#if os(Android)
+    // Android Glibc differs a little with respect to the Linux Glibc.
+
+    // IFF_LOOPBACK is part of the enumeration net_device_flags, which needs to
+    // convert to UInt32.
+    private extension UInt32 {
+        init(_ value: net_device_flags) {
+            self.init(value.rawValue)
+        }
+    }
+
+    // getnameinfo uses size_t for its 4th and 6th arguments.
+    private func getnameinfo(_ addr: UnsafePointer<sockaddr>?, _ addrlen: socklen_t, _ host: UnsafeMutablePointer<Int8>?, _ hostlen: socklen_t, _ serv: UnsafeMutablePointer<Int8>?, _ servlen: socklen_t, _ flags: Int32) -> Int32 {
+        return Glibc.getnameinfo(addr, addrlen, host, Int(hostlen), serv, Int(servlen), flags)
+    }
+#endif
+
 open class Host: NSObject {
     enum ResolveType {
         case name

    
    internal func _resolve() {
        guard _resolved == false else { return }
#if os(Android)
        return
#elseif os(Windows)
        if let info = _info {
          if _type == .current { return _resolveCurrent() }


    
    static internal func currentHostName() -> String {
#if os(Windows)
        var dwLength: DWORD = 0
        GetComputerNameExA(ComputerNameDnsHostname, nil, &dwLength)
        guard dwLength > 0 else { return "localhost" }

        guard let hostname: UnsafeMutablePointer<Int8> =
                UnsafeMutableBufferPointer<Int8>
                    .allocate(capacity: Int(dwLength + 1))
                    .baseAddress else {
            return "localhost"
        }
        defer { hostname.deallocate() }
        guard GetComputerNameExA(ComputerNameDnsHostname, hostname, &dwLength) else {
            return "localhost"
        }
        return String(cString: hostname)
#else
        let hname = UnsafeMutablePointer<Int8>.allocate(capacity: Int(NI_MAXHOST))
        defer {
