Jump to content

How to really set a TCPConnect timeout.


mbkowns
 Share

Recommended Posts

If I connect to a IP with TCPConnect( $g_IP, 80 ) and use a IP that went down or doesn't exist in DNS it has a huge delay for a response.

How can I make this faster?

I have tried setting with zero effect.

Opt("TCPTimeout",10)

$g_IP = "10.82.1.37"
Opt("TCPTimeout",10)

$time = @HOUR & ":" & @MIN & ":" & @SEC

; Start The TCP Services
;==============================================
TCPStartUp()

; Connect to a Listening "SOCKET"
;==============================================
$socket = TCPConnect( $g_IP, 80 )


msgbox(4096, "", $socket & @CR & "START: " & $time & @CR & "End: " & @HOUR & ":" & @MIN & ":" & @SEC) 

TCPShutdown()
Link to comment
Share on other sites

  • 3 weeks later...

Well, The only thing I can think of is to make 2 scripts...

(pseudo code, don't just copy+paste)

Script 1:

CODE

#NoTrayIcon

TCPStartup()

TCPConnection($myip, 80)

Func OnExit()

TCPShutdown()

EndFunc

Script 2:

CODE

$check = Run "Script 1"

sleep(500) ; Wait for as long as you want

if ProcessExists($check) Then

ProcessClose($check)

MsgBox(0, "Error", "Server is down")

EndIf

; Do your stuff

...

Let us know how that works... also, if someone has a less hacky way, please share with us :)

Link to comment
Share on other sites

  • 2 years later...

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...