Sign in to follow this  
Followers 0
Particle

TCPConnect/Array help

7 posts in this topic

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

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

#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

Share this post


Link to post
Share on other sites

#include <File.au3>

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

i have that include in there. i didnt' post the entire code.

the format is like this

201.1.5.22:1080

201.252.62.1:1080

etc.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Sorry. I forgot _FileReadToArray returns 1 or 0 and not the actual array.

Change this line:

$Array = _FileReadToArray ($file, $Array )

to

_FileReadToArray ($file, $Array )

Share this post


Link to post
Share on other sites

very nice thanks :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0