Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>Public Shared Function CheckProxy(ByVal Proxy As String) As Boolean Dim prx As Uri = Nothing If Uri.TryCreate(Proxy, UriKind.Absolute, prx) Then Return CheckProxy(prx) ElseIf Uri.TryCreate("http://" &amp; Proxy, UriKind.Absolute, prx) Then Return CheckProxy(prx) Else Return False End If End Function Public Shared Function CheckProxy(ByVal Proxy As Uri) As Boolean Dim iProxy As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) iProxy.ReceiveTimeout = 500 : iProxy.SendTimeout = 500 Try '' Connect using a timeout (1/2 second) Dim result As IAsyncResult = iProxy.BeginConnect(Proxy.Host, Proxy.Port, Nothing, Nothing) Dim success As Boolean = result.AsyncWaitHandle.WaitOne(500, True) If (Not success) Then iProxy.Close() : Return False End If Catch ex As Exception Return False End Try Dim bytData() As Byte, strData As String Dim iDataLen As Integer = 1024 strData = String.Format("CONNECT {0}:{1} HTTP/1.0{2}{2}", "www.google.com", 80, vbNewLine) bytData = System.Text.ASCIIEncoding.ASCII.GetBytes(strData) If iProxy.Connected Then iProxy.Send(bytData, bytData.Length, SocketFlags.None) ReDim bytData(1024) Do Try iDataLen = iProxy.Receive(bytData, bytData.Length, SocketFlags.None) Catch ex As Exception iProxy.Close() : Return False End Try If iDataLen &gt; 0 Then strData = System.Text.ASCIIEncoding.ASCII.GetString(bytData) Exit Do End If Loop Else Return False End If iProxy.Close() Dim strAttribs() As String strAttribs = strData.Split(" "c) If strAttribs(1).Equals("200") Then Return True Else Return False End If End Function </code></pre> <p>You should manage your code for threads etc, as suggested by @Nima for your proxy checking problem I have 2 methods here One asks proxy string and tries to connect it. e.g.</p> <pre><code>ProxyStatus = CheckProxy("http://192.168.1.1:8080/") </code></pre> <p>ProxyStatus is True/False depending on if proxy works or Not</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload