Sign in to follow this  
Followers 0
o0o

How to check proxy, sock live or die ?

5 posts in this topic

i'm writing a code to check proxy, live or die. Here my code:

Func CheckSocks($socks)
    TCPStartup()
    $_socks = StringSplit($socks, ":", 1)
    If $_socks[0] == 2 Then
        $ip = $_socks[1]
        $port = $_socks[2]
        $socket = TCPConnect($ip, $port)
    Else
        $socket = -1
    EndIf
    TCPShutdown()
    Return $socket
EndFunc  ;==>CheckSocks

plz help me!

Share this post


Link to post
Share on other sites



i'm writing a code to check proxy, live or die. Here my code:

Func CheckSocks($socks)
     TCPStartup()
     $_socks = StringSplit($socks, ":", 1)
     If $_socks[0] == 2 Then
         $ip = $_socks[1]
         $port = $_socks[2]
         $socket = TCPConnect($ip, $port)
     Else
         $socket = -1
     EndIf
     TCPShutdown()
     Return $socket
 EndFunc ;==>CheckSocks

plz help me!

Welcome to the AutoIt forums o0o :)

I don't think we can tell you much from just th efunction you posted because we don't know what the parameter is you are passing, or whether you have used or forgotten TCPStartUp().


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

$a = CheckSocks("173.3.220.236:32819")

Die => $a = -1

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$a = CheckSocks("173.3.220.236:32819")

Die => $a = -1

I think that the documentation in the help for TCPConnect is correct but at first read it looks like the value of @error will be either 1 or 2 if the connection fails whereas @error can be 0 when the connection fails. The value of @error is 1 or 2 if the IP or Port is invalid but even if both are valid it doesn't mean you will get a connection. So if there is no server listening on that IP and that port then TCPConnect fails, returns -1 but doesn't set @error. (Windows API WSAGetLasterror gives no error)

#include <winapi.au3>
 $a = CheckSocks("173.3.220.236:32819")
 
 
 Func CheckSocks($socks)
     Local $fault,$fault2
     TCPStartup()
     $_socks = StringSplit($socks, ":", 1)
     If $_socks[0] == 2 Then
         $ip = $_socks[1]
      ; ConsoleWrite($ip & @CRLF)
         $port = $_socks[2]
      ; ConsoleWrite($port & @CRLF)
         $socket = TCPConnect($ip, $port)
         $fault2 = _WSAGetLastError()
         if @extended Then
             msgbox (262144,"Fault","WSAGetLastError failed")
             $fault2 = 'unknown'
         EndIf
         
         If $socket = -1 Then
             Switch @error
                 Case 1
                     $fault = "Incorrect IP"
                 Case 2
                     $fault = "Incorrect port"
                 Case Else
                     $fault = "Valid IP and Port"
             EndSwitch
             MsgBox(262144, "Failed to connect","Error = " & $fault2 & @CRLF & $fault)
         EndIf
 
     Else
         $socket = -1
     EndIf
     TCPShutdown()
     Return $socket
 EndFunc ;==>CheckSocks
 
 Func _WSAGetLastError()
     Local $Res = DllCall("Ws2_32.dll", "int", "WSAGetLastError")
     If @error Then
         SetExtended(1)
         Return 0
     EndIf
     Return $Res[0]
 EndFunc ;==>_WSAGetLastError

I see I suggested you might not have used TCPStartup in my previous post but I had obviously not read your code properly, but if you use TCPShutdown in your function then you won't be able to use the returned socket later.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Is there any way to use a proxy found to be alive with IE or FF browsers?

Edited by Roman9

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