Jump to content

Reduce the timeout for TCPConnect


FaridAgl
 Share

Recommended Posts

Here is the code:

TCPStartup()

Global $hSocket = 0
For $i = 0 To 255
    $hSocket = TCPConnect("203.117.124." & $i, 7456)
    If (@error) Then ContinueLoop

    TCPCloseSocket($hSocket)
    $hSocket = 0

    ConsoleWrite("203.117.124." & $i & @CRLF)
Next

TCPShutdown()

It simply scans a rang of IPs with the defined port, and outputs the IPs which was available to connect via the specified port.

It's all good, works fine, but the only problem is the timeout for unsuccessful IPs.

For example, if it connect to 203.117.124.0 it will quickly jump to the next IP, but if it fail to connect to one of those IP, it somehow stuck for a while (about 15 ~ 25 seconds for each fail).

I have tried TCPTimeout, with no success. Anyone knows any better way?

Thanks.

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