We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 63,829 times

Contents

Downloads

Related Categories

Pinging a host from VB .net - Introduction

MstrControl

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.

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 experience in systems analysis, working and developing systems in Visual Basic, Visual C++, Java, Delphi, Websites (HTML/ASP) etc.

Comments

  • Re: [2857] Pinging a host from VB .net

    Posted by stev-io on 20 Jul 2006

    i found it works ok until you get a timeout. the Do Loop Unitl loop in the reply hangs and then throws an exception. i changed the loop to a try catch and the catch checks to see if there was a timeou...

  • Posted by WATYF on 23 Nov 2005

    I put it right at the beginning of the Ping function. (after the variable declarations)


    FYI... .NET 2.0 has a ping Class built in that you can use to ping in .NET apps.... you may want to check i...

  • Posted by Raven096 on 22 Nov 2005

    I'm new to VB and VB.NET, where did you add: If udtError.Number = PING_ERROR_HOST_NOT_FOUND Then Return (PING_ERROR) ?

    I'm having the same problem if the host doesn't exist and I'm trying to fix it...

  • Ping using WMI

    Posted by nielsvdc on 16 Nov 2005

    Public Shared Function Ping(ByVal address As String) As Boolean
    Dim objPing As New Management.SelectQuery("SELECT StatusCode FROM Win32_PingStatus WHERE Address = '" & address & "...

  • Posted by TGerlach on 30 Aug 2005

    Sorry for the long response to give you an answere. My english isn't good enought to translate my site into a correct english. But I have post some samples on my site, download the samlples an you wil...