GitHub wouldn't load for me for some reason. But judging by the "ProxyScraper" git project in the URL, I'd assume you're trying to open web traffic to test a proxy with a TCPClient? If that's what you're trying to do then a TCPClient is over-engineering your solution.
Try this (**NOTE: This was done in notepad from memory, please ignore the ugly capitalization/inconsistent casing):
Code
public sub Main()
Dim Proxies as new List(Of WebProxy)
'Load list of proxies here using Proxies.Add(new WebProxy("HOST:PORT", True))
For Each Proxy as WebProxy in Proxies.ToArray()
if ProxyWorks(Proxy) then
'Working Proxy!
else
'Non-working Proxy!
end if
next
End Sub
public function ProxyWorks(Proxy as WebProxy) as Boolean
dim ProxyTestClient as new WebClient()
ProxyTestClient.Proxy = Proxy
try
if ProxyTestClient.DownloadString("URL") <> Nothing then
return true
end if
catch Ex as Exception
'Up to you if you'd like to do more complex error-handling here, e.g.: determine WHY the proxy failed, etc.
return false
end try
end function
And if you want to get really fancy/clean with it, figure out how to do it all asynchronously! 🤝