o0o Posted May 22, 2009 Share Posted May 22, 2009 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! Link to comment Share on other sites More sharing options...
martin Posted May 22, 2009 Share Posted May 22, 2009 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. Link to comment Share on other sites More sharing options...
o0o Posted May 23, 2009 Author Share Posted May 23, 2009 $a = CheckSocks("173.3.220.236:32819") Die => $a = -1 Link to comment Share on other sites More sharing options...
martin Posted May 23, 2009 Share Posted May 23, 2009 (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) expandcollapse popup#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 May 23, 2009 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. Link to comment Share on other sites More sharing options...
Roman9 Posted May 31, 2009 Share Posted May 31, 2009 (edited) Is there any way to use a proxy found to be alive with IE or FF browsers? Edited May 31, 2009 by Roman9 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now