Function Reference


_TCPIpToName

Resolves IP address to Hostname(s)

#include <Inet.au3>
_TCPIpToName ( $sIp [, $iOption = 0 [, $hDll = "Ws2_32.dll"]] )

Parameters

$sIp Ip Adress in dotted (v4) Format
$iOption [optional] Default = 0
0 = Return String Hostname
1 = Return Array (see Remarks)
$hDll [optional] Handle to Ws2_32.dll

Return Value

Success: Hostname or Array (see Remarks)
Failure: ""
@error: 1 - inet_addr DllCall Failed
2 - inet_addr Failed
3 - gethostbyaddr DllCall Failed
4 - gethostbyaddr Failed, WSAGetLastError = @extended
5 - gethostbyaddr Failed, WSAGetLastError Failed
6 - strlen/sZStringRead Failed
7 - Error reading Aliases Array

Remarks

A successfull WSAStartup (Done by TCPStartup()) is required.
if $iOption = 1 then the returned Array looks Like this:
    $aResult[0] = Number of elements
    $aResult[1] = "Hostname"
    $aResult[2] = "Alias 1"
    $aResult[3] = "Alias 2"
    ...

Example

Example 1

#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $aResult, $sResult, $sIp

TCPStartup()
$sIp = TCPNameToIP("autoitscript.com")
$sResult = _TCPIpToName($sIp)
If @error Then
        MsgBox($MB_SYSTEMMODAL, "_TCPIpToName()", "@error = " & @error & @CRLF & "@extended = " & @extended)
Else
        MsgBox($MB_SYSTEMMODAL, "autoitscript.com really is: ", $sResult)
EndIf

Example 2

#include <Array.au3>
#include <Inet.au3>
#include <MsgBoxConstants.au3>

Local $aResult, $sResult, $sIp

TCPStartup()
$sIp = _GetIP()
$aResult = _TCPIpToName($sIp, 1)
If @error Then
        MsgBox($MB_SYSTEMMODAL, "_TCPIpToName()", "@error = " & @error & @CRLF & "@extended = " & @extended)
Else
        _ArrayDisplay($aResult, "Local Hostname(s)")
EndIf