Author |
Topic: Network "Ping" Check (Read 858 times) |
|
Mystic
Junior Member
member is offline
Gender:
Posts: 53
|
|
Network "Ping" Check
« Thread started on: Aug 4th, 2015, 4:56pm » |
|
Was wondering if anyone has another way to do a ping check on a machine on a network?
I know I can generate a .bat file with the ping instructions, then run the .bat from my program piping it to a data file, then...whew...reading the data file to see if the ping was successful.
Thanks,
|
|
Logged
|
- Rick
|
|
|
Mystic
Junior Member
member is offline
Gender:
Posts: 53
|
|
Re: Network "Ping" Check
« Reply #2 on: Aug 4th, 2015, 7:14pm » |
|
Awesome!
Thanks Richard!
|
|
Logged
|
- Rick
|
|
|
Mystic
Junior Member
member is offline
Gender:
Posts: 53
|
|
Re: Network "Ping" Check
« Reply #3 on: Aug 4th, 2015, 7:17pm » |
|
Looks like this just checks if the computer you're on can connect to the internet.
I need to ping specific machines to see if they are connected...
|
|
Logged
|
- Rick
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: Network "Ping" Check
« Reply #4 on: Aug 4th, 2015, 9:09pm » |
|
on Aug 4th, 2015, 7:17pm, Mystic wrote:Looks like this just checks if the computer you're on can connect to the internet. I need to ping specific machines to see if they are connected... |
|
The MSDN page I linked to in my reply states explicitly: "If lpszUrl is non-NULL, the host value is extracted from it and used to ping that specific host". Do I assume you've tried it and it doesn't work?
Richard.
|
|
Logged
|
|
|
|
Mystic
Junior Member
member is offline
Gender:
Posts: 53
|
|
Re: Network "Ping" Check
« Reply #5 on: Aug 4th, 2015, 11:11pm » |
|
on Aug 4th, 2015, 9:09pm, Richard Russell wrote:Do I assume you've tried it and it doesn't work? |
|
No assuming... I'll write some code and play with it. I was going by...
"Allows an application to check if a connection to the Internet can be established."
Thanks again...
|
|
Logged
|
- Rick
|
|
|
Mystic
Junior Member
member is offline
Gender:
Posts: 53
|
|
Re: Network "Ping" Check
« Reply #6 on: Sep 10th, 2015, 9:51pm » |
|
Here's my not so elegant solution I threw together.
I'm sure many of you will snicker at my coding, but it's working for now.
Code:[pingMachine]
' Create a batch file with the ping information...
success = 0
pingReply = 0
success$ = ""
OPEN "gather.bat" FOR OUTPUT AS #batch
PRINT #batch, "@echo off"
pingLine$ = "ping " + addressUrl$ + " > pingresults.dat"
PRINT #batch, pingLine$
CLOSE #batch
GOSUB [pauseProgramShort]
RUN "gather.bat", HIDE
GOSUB [pauseProgram]
' Printing out ping file for testing...
OPEN "pingresults.dat" FOR INPUT AS #pingDisplay
WHILE NOT(EOF(#pingDisplay)<>0)
LINE INPUT #pingDisplay, printPingLine$
IF LEFT$(printPingLine$, 10) = "Reply from" success = success + 1
PRINT printPingLine$
WEND
CLOSE #pingDisplay
IF success >= 3 THEN
pingReply = 1
success$ = addressUrl$ + " SUCCESS"
PRINT success$
PRINT "=================================================================="
END IF
PRINT
' If there is no reply let the program know that there is activity during this hour...
IF pingReply = 0 THEN activity = 1
RETURN
|
|
Logged
|
- Rick
|
|
|
|