Jump to content

TCPConnect/Array help


 Share

Recommended Posts

Ok I am having this probem with one of my programs thats driving me crazy. It's a fast proxy testing program where u can load a text file of proxies and it's suppose to test them and tell u which ones are still alive or if they died out. I don't know if I wrote the arrays wrong or what but it seems to not work and all the proxies are just showing up as "Disconnected" expecially on ones that i know are alive. Help?

If $msg = $fptload Then
        $file = FileOpenDialog("Choose file...",@WorkingDir,"Text Documents (*.txt)")
        TCPStartup()
        $Count = _FileCountLines($file)
        $i = 1
        Dim $Array[$Count]
        Do 
            $Array[$i] = FileReadLine($file,$i)
            $port = StringSplit($Array[$i],":")
            $tcprun = TCPConnect($Array[$i],$port[2])
            If $tcprun = -1 Then
                GuiCtrlCreateListViewItem($Array[$i]&"|Disconnected",$proxylist)
            Else
                GuiCtrlCreateListViewItem($Array[$i]&"|Connected",$proxylist)
            EndIf
            $i = $i + 1
        Until $i = $Count
        TCPShutdown()
    EndIf
Link to comment
Share on other sites

#include <File.au3>

If $msg = $fptload Then
        $file = FileOpenDialog("Choose file...",@WorkingDir,"Text Documents (*.txt)")
        TCPStartup()
        
        Dim $Array
        $Array = _FileReadToArray ($file, $Array )
        
        If $Array[0] = 0 Then
            MsgBox(0,"", "File is empty")
        EndIf
        
        For $i = 1 to $Array[0]
            $port = StringSplit($Array[$i],":")
            $tcprun = TCPConnect($Array[$i],$port[2])
            
            Switch @error
                Case 1
                    MsgBox(0,"","Ip address is incorrect")
                Case 2
                    MsgBox(0,"","Port is incorrect")
            EndSwitch
                    
            If $tcprun = -1 Then
                GuiCtrlCreateListViewItem($Array[$i]&"|Disconnected",$proxylist)
            Else
                GuiCtrlCreateListViewItem($Array[$i]&"|Connected",$proxylist)
            EndIf
        Next
        TCPShutdown()
EndIf

EDIT: What format is the data in your text file being read?

Edited by weaponx
Link to comment
Share on other sites

I see the problem. You were calling TCPConnect like this TCPConnect("201.1.5.22:1080", "1080")

If $msg = $fptload Then
        $file = FileOpenDialog("Choose file...",@WorkingDir,"Text Documents (*.txt)")
        TCPStartup()
       
        Dim $Array
        $Array = _FileReadToArray ($file, $Array )
       
        If $Array[0] = 0 Then
            MsgBox(0,"", "File is empty")
        EndIf
       
        For $i = 1 to $Array[0]
            $temp = StringSplit($Array[$i],":")
            $ipAddress = $temp[1]
            $port = $temp[2]
            
            $tcprun = TCPConnect($ipAddress,$port)
           
            Switch @error
                Case 1
                    MsgBox(0,"","Ip address is incorrect")
                Case 2
                    MsgBox(0,"","Port is incorrect")
            EndSwitch
                   
            If $tcprun = -1 Then
                GuiCtrlCreateListViewItem($Array[$i]&"|Disconnected",$proxylist)
            Else
                GuiCtrlCreateListViewItem($Array[$i]&"|Connected",$proxylist)
            EndIf
        Next
        TCPShutdown()
EndIf
Edited by weaponx
Link to comment
Share on other sites

i tried that piece of code u wrote there and i got this:

>"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Au3 Files\FPT.au3"

C:\Au3 Files\FPT.au3 (26) : ==> Subscript used with non-Array variable.:

If $Array[0] = 0 Then

If $Array^ ERROR

>Exit code: 1 Time: 5.946

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