🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
11 messages
11 total messages Started by MR Thu, 23 Nov 2006 09:13
How to check, if my LAN-connection is currently available or not?
#1699
Author: MR
Date: Thu, 23 Nov 2006 09:13
11 lines
992 bytes
How to check, if my connection is currently available or not?

If I loose my connection (or it get back) Windows displays an adequate
message.

Can I test this connection-state inside my application?


Thanks,

Michael
Re: How to check, if my LAN-connection is currently available or not?
#1700
Author: Hans Galema
Date: Thu, 23 Nov 2006 10:49
10 lines
1210 bytes
MR wrote:
> How to check, if my connection is currently available or not?

Do you mean your connection to the internet?

You can use TIDHttp to connect to a server on the internet.

If that succeeds: connection.

Hans.
Re: How to check, if my LAN-connection is currently available or not?
#1704
Author: MR
Date: Thu, 23 Nov 2006 16:03
24 lines
1719 bytes
Hans Galema <notused@notused.nl> schrieb:

>MR wrote:
>> How to check, if my connection is currently available or not?
>
>Do you mean your connection to the internet?
Yes, but I would appreciate the same when e.g. copying a file from one
computer to another using my TCP/IP connection (LAN).

>You can use TIDHttp to connect to a server on the internet.
>
>If that succeeds: connection.

The problem is more, to check the reason why a download does not
succeed. Is the file not available or did I loose my connection.

Perhaps I should add, my Laptop has some difficuly to hold the
Ethernet-cable so it sometimes slips out. So if it does I could handle
this quickly with e.g. an alarming sound, forcing me to plug it in
immediately... ;-)

Thanks,

Michael
Re: How to check, if my LAN-connection is currently available or not?
#1705
Author: Erol Fornoles
Date: Thu, 23 Nov 2006 16:24
27 lines
2295 bytes
Trying doing a UDP broadcast. If it throws an exception, you're not
connected to the LAN.

- Erol

On Nov 24, 12:03 am, <MR> wrote:
> Hans Galema <notu...@notused.nl> schrieb:
>
> >MR wrote:
> >> How to check, if my connection is currently available or not?
>
> >Do you mean your connection to the internet?Yes, but I would appreciate the same when e.g. copying a file from one
> computer to another using my TCP/IP connection (LAN).
>
> >You can use TIDHttp to connect to a server on the internet.
>
> >If that succeeds: connection.The problem is more, to check the reason why a download does not
> succeed. Is the file not available or did I loose my connection.
>
> Perhaps I should add, my Laptop has some difficuly to hold the
> Ethernet-cable so it sometimes slips out. So if it does I could handle
> this quickly with e.g. an alarming sound, forcing me to plug it in
> immediately... ;-)
> 
> Thanks,
> 
> Michael
Re: How to check, if my LAN-connection is currently available or not?
#1706
Author: Erol Fornoles
Date: Thu, 23 Nov 2006 16:28
3 lines
1422 bytes
I meant "Try doing a UDP broadcast." in my previous post. Sorry.

- Erol
Re: How to check, if my LAN-connection is currently available or not?
#1707
Author: Hans Galema
Date: Thu, 23 Nov 2006 16:59
10 lines
1214 bytes
MR wrote:

> ... my Laptop has some difficuly to hold the
> Ethernet-cable so it sometimes slips out.

Ahaaa! A hardware problem!

A new plug?

Hans.
Re: How to check, if my LAN-connection is currently available or not?
#1710
Author: MR
Date: Tue, 28 Nov 2006 06:42
18 lines
1519 bytes
>Ahaaa! A hardware problem!
Yes, kind of, but no real serious one.

>A new plug?
No, to expensive.

And it has the advantage, that, if you move fast with the laptop and
the cable reached it's end it will simply slip out instead of pushing
back your laptop and thus creating more serious hardware problems,
e.g. when it slips out of your hands and fall onto the floor.  ;-)

So again: no way to find out if connection is lost (or as alternative:
no way to find out if this connection-lost icon is displayed on the
task-bar)?

Thanks,

Michael
Re: How to check, if my LAN-connection is currently available or not?
#1711
Author: Tom
Date: Tue, 28 Nov 2006 08:32
7 lines
1298 bytes
Try this: 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/inetisoffline.asp

I use it in my programs and it seems to work well, as far back as Win95 and 
NT

-Tom 
Re: How to check, if my LAN-connection is currently available or not?
#1712
Author: MR
Date: Tue, 28 Nov 2006 12:16
61 lines
2768 bytes
"Tom" <tom@nospam.net> schrieb:

>Try this: 
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/inetisoffline.asp
>
>I use it in my programs and it seems to work well, as far back as Win95 and 
>NT
 
Thanks for you answer.

I tried

if(InetIsOffline(0/*dwFlags*/)) {
    Beep();
    Sleep(50);
    Beep();
  }

but unfortunately I never un into this Beep()-block.

I'm not so sure, what MS means with

  Returns FALSE if ... if no attempt has yet been made to connect to
the Internet.

I use TIdHTTP::Get() to download a file. If I plug out the
ethernet-cable while downloading and thus make Get() fail and
afterwards call InetIsOffline() this function also returns FALSE.

~~~~

I just found further explanation in the header-file:

//   Off-line mode begins when the user has been prompted to dial-in
to
//  an Internet providor, but canceled the attempt.

So perhaps this module it just sets a global var to the offline-value
to TRUE if it's own try to dial-in failed. If no try is made from
winthin this module, it stays FALSE (=online). 

So if the dial-in is made by another module/class it is not
recognized...

~~~~~~~~~~~~~~~~

Btw. having DSL I never explicitely dial in. I suppose there is just a
test, if my DSL-MOdem is available (by trying to access it by a
certain TCP/IP-Address) and if not the connection failed.

??? What about trying to ping it? Could this be the solution to my
problem? 

Could it really be so hard to find this out, when even windows
displays the state it in the task-bar explicitely?


Thanks,

Michael
 
Re: How to check, if my LAN-connection is currently available or not?
#1713
Author: PaoloItaly
Date: Tue, 28 Nov 2006 13:45
19 lines
1481 bytes
<MR> ha scritto nel messaggio 
news:4bpam21rfr9noj29g2ol5jp008gekpvuf8@4ax.com...
> How to check, if my connection is currently available or not?
>
> If I loose my connection (or it get back) Windows displays an adequate
> message.
>
> Can I test this connection-state inside my application?
>
>
> Thanks,
>
> Michael

Look at :
::IsNetworkAlive
::InternetGetConnectedState and ::InternetCheckConnection

Paolo 
Re: How to check, if my LAN-connection is currently available or not?
#1720
Author: MR
Date: Sun, 03 Dec 2006 05:25
34 lines
1900 bytes
Thanks for your helpful answer.

>Look at :
>::IsNetworkAlive
>::InternetGetConnectedState and ::InternetCheckConnection

The first two functions seem to return the state I has asked for:
 for the fist a DLL seems necessary, 
  for the second a library included:
    #pragma comment(lib, "wininet.lib") 

In my case with them I can find out, if there is a connection between
my laptop and the dsl-network-router. 


More for fun as for need I cut the connection between the Internet and
the dsl-network-router, i.e. I could access to the LAN, but not to the
internet any more.

The result was, that both functions return a value, which means the
inernet-connection is correct.

Is there a better way to find out if the connection to the internet is
available than trying to download a small page/file from a site, known
as available.

[As said, I'm quite happy with the functions above, but tending to
make things as perfect as possible this would  be even better.]


Thanks,

Michael 
 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads