private static unsafe bool TryGetHostByAddr(Interop.libc.in_addr address, byte *buffer, int bufferSize, Interop.libc.hostent *hostent, Interop.libc.hostent **result) { int errno; int err = Interop.libc.gethostbyaddr_r(&address, (uint)sizeof(Interop.libc.in_addr), Interop.libc.AF_INET, hostent, buffer, (IntPtr)bufferSize, result, &errno); switch (Interop.Sys.ConvertErrorPlatformToPal(err)) { case 0: return(true); case Interop.Error.ERANGE: return(false); default: throw new InternalSocketException(GetSocketErrorForErrno(errno), errno); } }
private static unsafe bool TryGetHostByName(string hostName, byte *buffer, int bufferSize, Interop.libc.hostent *hostent, Interop.libc.hostent **result) { int errno; int err = Interop.libc.gethostbyname_r(hostName, hostent, buffer, (IntPtr)bufferSize, result, &errno); switch (Interop.Sys.ConvertErrorPlatformToPal(err)) { case 0: return(true); case Interop.Error.ERANGE: return(false); default: throw new InternalSocketException(GetSocketErrorForErrno(errno), errno); } }