LB Booster
« Network "Ping" Check »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:38am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Network "Ping" Check  (Read 858 times)
Mystic
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 53
xx 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,
User IP Logged

- Rick
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Network "Ping" Check
« Reply #1 on: Aug 4th, 2015, 7:06pm »

on Aug 4th, 2015, 4:56pm, Mystic wrote:
Was wondering if anyone has another way to do a ping check on a machine on a network?

Windows InternetCheckConnection API:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa384346.aspx

Very easily called from LB or LBB.

Richard.
User IP Logged

Mystic
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 53
xx Re: Network "Ping" Check
« Reply #2 on: Aug 4th, 2015, 7:14pm »

Awesome!

Thanks Richard!
User IP Logged

- Rick
Mystic
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 53
xx 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...
User IP Logged

- Rick
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

Mystic
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 53
xx 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...
User IP Logged

- Rick
Mystic
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 53
xx 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
 
User IP Logged

- Rick
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls