Pinging a host from VB .net

Page 1 of 2
  1. Introduction
  2. The Code

Introduction

Greetings, Developers.

This class started because I was developping a server monitor and I needed a way to detect if the server was down or not.

So the easiest way to know is pinging the server, right? Wrong. Well... almost.

I started searching the web and I found a code developped for C# and after a few bumps I converted to VB .NET and the code works fine, up to the point of performance.

I use System.Net.Sockets.Socket to create and send a Raw packet of data to send to the host. The send part works fine, but the response (when I lesten for the echo of the packet I just sent) takes ages to process. I've checked the docs on Microsoft about the System.Net.Sockets.Socket.ReceiveFrom to see if they have some insight about what's going on, and finally found a solution - here it is!

UPDATE!

I have included an working sample of this class. Hope you like it.



Best Regards,

Paulo Silva Jr.

You might also like...

Comments

 MstrControl For the last twelve years I've been working for several companies, varying in sizes and actuation areas, but always trying to improve myself as well the company I was working for. I have deep exper...

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” - Brian Kernighan