Jump to content

tcpconnect handle hostnames?


gcue
 Share

Recommended Posts

i have a script that does telnet testing but i dont know how to account for hostnames

because i dont think tcpconnect can use hostnames - i get erroneous results...

or perhaps a way to convert to ip if the entry is a hostname?

here is my script

#include <GUIConstantsEx.au3>
#include <Array.au3>

Global $socket, $ecns, $ip, $ini = "servers.ini"

If Not FileExists($ini) Then
    MsgBox(0, "ERROR", "Servers.ini does not exist in script directory.")
EndIf

$ecns = IniReadSectionNames($ini)

TCPStartUp()

for $n = 1 to $ecns[0]
    

        $ip = IniRead($ini, $ecns[$n], "IP", "NOT FOUND")
        $port = IniRead($ini, $ecns[$n], "PORT", "NOT FOUND")
;MsgBox(0, "", $ecns[$n] & " " & $ip & " " & $port)
        

$socket = TCPConnect($ip, $port)

If $socket = -1 Then
    MsgBox(0, "ERROR!", $ecns[$n] & " cannot connect." & @CRLF & _
    "IP: " & $ip & @CRLF & _
    "PORT: " & $port & @CRLF & _
    ""& @CRLF & _
    "NOTE: use IPS not HOSTNAMES in servers.ini file")
Else
    MsgBox(0, "SUCCESS!", $ecns[$n] & " connected successfully." & @CRLF & _
    "IP: " & $ip & @CRLF & _
    "PORT: " & $port)
EndIf

TCPCloseSocket($socket)

Next

TCPShutDown()

and my INI

[LAVA1]

IP=209.208.175.166

PORT=4001

[PIPELINE1]

IP=208.72.213.65

PORT=9000

[PIPELINE2]

IP=64.242.18.189

PORT=9000

[LIQUIDNET1]

IP=prod1.liquid-net.com

PORT=5101

[LIQUIDNET2]

IP=206.16.8.141

PORT=5101

Edited by gcue
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...