How to check for internet connection

J

Jonny

Hi,

Please could you tell me how to check for an internet connection in C.
I'm using Windows 2000.

Many Thanks,
Jonny
 
W

Walter Roberson

:please could you tell me how to check for an internet connection in C.
:I'm using Windows 2000.

How do you want to define "an internet connection" ?

If I'm using a system connected up to a multi-continent dedicated
research network with ten thousand or so members, does that qualify
as an "internet connection" ?

If I'm using a system that is nailed down and firewalled so tightly
that the -only- thing that can go out on the network is NTP time
synchronization with *one* system, then is that "an internet connection" ?


C itself has no concept of internet connections, so you will have
to use an external facility to do the work.

If you want your definition of "internet connection" to be "there is
some kind of network card, wired or wireless, ethernet or token ring or
even direct IBM SNA, and that NIC is showing that a carrier signal
exists to the card" then you are going to have to use something that is
pretty Windows specific, as there is no portable way to find out what
hardware is attached or details of its state. In such a case, you would
need to use the Windows 32 ABI, probably.

If you want your definition of "internet connection" to be "is able
to send through the network and make a TCP connection to a particular
endpoint" then you can possibly use POSIX standard sockets to just
*try* the connection and see what happens. [Though I seem to recall
reading the Windows 2000 is only fractionally POSIX, with the POSIX
integration being more advanced in XP.]
 
J

Jonny

Walter said:
C itself has no concept of internet connections, so you will have
to use an external facility to do the work.

Thanks for your reply Walter.

I'm quite new to this, so I would be grateful if you could explain the
above to me. Do you mean that I call an external utility from within my
C program, and then get the result from it?

If I have an executable which sets an error level on Windows 2000 if
there is no "internet connection", can I run this executable and access
that error level from within my C program? Or if the executable outputs
some error text, can my C program read that text?

Your help is appreciated.

Regards,
Jonny
 
N

Neil Kurzman

Jonny said:
Thanks for your reply Walter.

I'm quite new to this, so I would be grateful if you could explain the
above to me. Do you mean that I call an external utility from within my
C program, and then get the result from it?

Some library or extension that is for your system O/S
If I have an executable which sets an error level on Windows 2000 if
there is no "internet connection", can I run this executable and access
that error level from within my C program? Or if the executable outputs
some error text, can my C program read that text?

Yes You can lookup the system() function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top