Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ping a server from VB.net via a specific proxy

I know that you can easily send a ping request and receive a boolean return type in .NET, using something like:

If My.Computer.Network.Ping(addressToPing_str, pingTimeOutMS_int) Then
    MessageBox.Show("Ping successful")
End If

But this appears to use the proxy that it set globally for windows (Looks like it uses the same setting that internet explorer uses.)

What i want to do is specify my own IP and port to use as a proxy, instead of using the windows global value or whatever it is...

There will be multiple applications running at once, and indeed multiple pings at once, as my application checks multiple servers in parallell. Therefore, changing the global value, sending a ping, then setting it back is not an option.


So my question is - Is there any alternate method of sending a ping request that will also allow me to specify what proxy server I want to use?

Thanks!

like image 853
Allen Avatar asked Feb 03 '26 06:02

Allen


1 Answers

Setup a Web Service in a location visible to all of the nodes you want to ping. Make a method on the webservice called Public Function Ping(Byval ipAddress As String) As Int32

Then in your application consume the Web Service and invoke the Async methods that the code generates when you first consume the Web Service. The Async methods allow for some degree of this 'parallellization' that you speak of.

Invoke the PingAsync with a callback.

The Web Service acts as your 'Proxy' and will be accessible via HTTP. You can then invoke a Ping even on a client with ICMP traffic blocked.

Edit:

If you just want to test a HTTP proxy for a valid connection you can use the WebRequest/WebClient classes and download a small file on a remote computer.

Information is available here: http://msdn.microsoft.com/en-us/library/2s8th0s1.aspx and a console example is available here: http://msdn.microsoft.com/en-us/library/system.net.webrequest.proxy.aspx

WebRequest.Proxy will allow you to specify the HTTP proxy and the credentials passed. You could then load say http://www.whatismyip.org/ and check to see if you get a response. If you get a response then your HTTP proxy is working.

like image 174
Jeremy Avatar answered Feb 04 '26 22:02

Jeremy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!