![]() |
Pinger suggestions?
I've wrote a little program to ping servers and report the results. I'd be interested in ways I could have done it better if you don't mind.
:
|
Re: Pinger suggestions?
Well, it's a rare occasion when a new programmer does it absolutely right.
|
Re: Pinger suggestions?
To me, another relatively new programmer (only been doing it about 2 years) it looks fine. I'd always try to comment my code a bit more though.
I'll see if some of the more experienced guys have comments though.... |
Re: Pinger suggestions?
You want comments of course.
With reference to functionality, I couldn't say; I've never written a pinger before. If you wanted to get nifty and write very little code, just use the ping system command: :
ping -n 1 -w 2000 google.caWhich could be used in Visual Basic like so: :
This way's a lot simpler because it handles all exceptions for you. If the ping doesn't work, ping.exe handles that for you. And if you want to get nit-picky, I'd turn Chr(13) & Chr(10) into a constant, CRLF (if the constant does not already exist), and reference that, instead of having that annoying code repeating 3-4 times. Especially since CRLF is often something you want to change.Then turn your PadRight 30's and 20's into some sort of constant MarginRight variable, and base your calculations off that.Finally, your ping timeout of 2000ms could be user defined as a textCtrl or slider in the Graphical Interface, or referenced as another constant, PingTimeout. |
Re: Pinger suggestions?
Shell opens a command window? I'd rather keep the open windows to a minimum, seems to be less things to cause problems since there will be more than one person accessing the computer this will be running on. Also, some of these people are not very technically astute, even after "training".
|
Re: Pinger suggestions?
There should be a way to pipe the output of ping.exe right into a variable you can even use, without any other windows opening.
Look for popen or something. |
| All times are GMT -5. The time now is 8:10 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC