Jump to content

Recommended Posts

Posted

How it works:

$test = INET_TEST_CONNECTION($ip , $port , $timeout)

timeout is in milliseconds

no more gui freazing when trying to connect to a port just test it first

#include<Constants.au3>
#include<GUIConstantsEx.au3>

Opt("GUIOnEventMode" , 1)
GUICreate('ss')
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
GUISetState()

MsgBox(0 , "Bad test" ,INET_TEST_CONNECTION("86.55.211.38" , 65001)) ; blocked from the firewall
MsgBox(0 , "Good test" ,INET_TEST_CONNECTION("86.55.211.38" , 80))   ; open for business
While 1
    Sleep(100)
WEnd

Func INET_TEST_CONNECTION($IP , $PORT, $TIMEOUT = 100)
    Local $pid = Run(@AutoItExe & ' /AutoIt3ExecuteLine  "ConsoleWrite(TCPCloseSocket(TCPConnect(' & "'" & $IP & "'" & ', 0 * TCPStartup() + ' & $PORT & ')))"',@ScriptDir,@SW_HIDE,$STDOUT_CHILD)
    Local $data = ""
    Local $start = TimerInit()
    While ProcessExists($pid) And TimerDiff($start)<$TIMEOUT
        $data &= StdoutRead($pid)
        Sleep(10)
    WEnd
    $data &=StdoutRead($pid)
    ProcessClose($pid)
    If $data = "" Then Return False
    Return $data
EndFunc

Func quit()
    Exit
EndFunc

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

  • 5 months later...
Posted

How it works:

$test = INET_TEST_CONNECTION($ip , $port , $timeout)

timeout is in milliseconds

no more gui freazing when trying to connect to a port just test it first

#include<Constants.au3>
#include<GUIConstantsEx.au3>

Opt("GUIOnEventMode" , 1)
GUICreate('ss')
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
GUISetState()

MsgBox(0 , "Bad test" ,INET_TEST_CONNECTION("86.55.211.38" , 65001)) ; blocked from the firewall
MsgBox(0 , "Good test" ,INET_TEST_CONNECTION("86.55.211.38" , 80))   ; open for business
While 1
    Sleep(100)
WEnd

Func INET_TEST_CONNECTION($IP , $PORT, $TIMEOUT = 100)
    Local $pid = Run(@AutoItExe & ' /AutoIt3ExecuteLine  "ConsoleWrite(TCPCloseSocket(TCPConnect(' & "'" & $IP & "'" & ', 0 * TCPStartup() + ' & $PORT & ')))"',@ScriptDir,@SW_HIDE,$STDOUT_CHILD)
    Local $data = ""
    Local $start = TimerInit()
    While ProcessExists($pid) And TimerDiff($start)<$TIMEOUT
        $data &= StdoutRead($pid)
        Sleep(10)
    WEnd
    $data &=StdoutRead($pid)
    ProcessClose($pid)
    If $data = "" Then Return False
    Return $data
EndFunc

Func quit()
    Exit
EndFunc

Thats a great funktion, can't find any other script that will let me have a timeout for a connection, but thing is, it leaves an Autoit running after you use the script, so i have to close that manually, i wish i could close that with in the script. But i'll admit that your funktion is a bit to advanced for me to figure out how to change so it will do that?
Posted

Thats a great funktion, can't find any other script that will let me have a timeout for a connection, but thing is, it leaves an Autoit running after you use the script, so i have to close that manually, i wish i could close that with in the script. But i'll admit that your funktion is a bit to advanced for me to figure out how to change so it will do that?

huh?
Opt("TCPTimeout",100)
Posted

huh?

Opt("TCPTimeout",100)

I found out that i had made an error and used a loop part wrong in the script, and changed that, how ever i've been trying to use the TCPtimeout, but seemingly the effect is ignored, and what i can read on the forum, the effect of it, is bugged and does nothing, and has yet to be fixed.

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
×
×
  • Create New...