   
   /* run lookup (synchronously, can be slow!) */
   var rc = name.withCString { (cs : CString) -> Int32 in
-    getaddrinfo(cs, CString(nil), &hints, &ptr)
+    let ncs = CString(UnsafePointer<CChar>.null())
+    return getaddrinfo(cs, ncs, &hints, &ptr)
+  }
+  if rc != 0 {
+    cb(name, nil)
+    return
   }
   
   /* copy results - we just take the first match */

  cb(name, cn, addr)
}

/* swiftc crashes, can't get this right (array of tuples)
func gethostzbyname<T: SocketAddress>
  (name : String, flags : Int32 = AI_CANONNAME,
   cb   : [( String, ( cn: String?, address: T?)]? ) -> Void)
{
  // Note: I can't just provide a name and a cb, swiftc will complain.
  var hints = addrinfo()

  
  cb(name, results)
}
