CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 5 of 8 FirstFirst ... 2345678 LastLast
Results 61 to 75 of 111
  1. #61
    Join Date
    Feb 2003
    Location
    Bangalore, India
    Posts
    1,354
    Originally posted by anima_sg
    but when i did this with CAysncsocket the sequence was different. Now the questoin is to recreate the magical sqquence or use the connect with timeout ...........
    You have to use winsock APIs rather than CSockets. For such situations you need to have more control over what is happening...so APIs are the best.
    Originally posted by jase jennings
    Thanks for your post. I checked your code and it failed immediately
    I think what Jase should do is to choose one of the method that suits the situation. The user should have the responsibility to fix the problem. Well, to know if there is net connection we all use IE to check. So I think we should follow the approach that IE uses. Searching for the 'fool proof' solution if one doesn't exist is just a waste of time. In the course of time, if someone gets such a solution, please participate us with it.
    Even if our suggestions didn't help, please post the answer once you find it. We took the effort to help you, please return it to others.

    * While posting code sections please use CODE tags
    * Please check the codeguru FAQ and do a little search to see if your question have been answered before.
    * Like a post, Rate The Post
    * I blog: Network programming, Bible

    I do all things thru CHRIST who strengthens me

  2. #62
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626
    The IE way isn't foolproof either. I'm running my internet off a DSL/LAN.
    When I installed WinXP, and started IE, it always popped up a dial-up networking (DUN) connection dialog, which I don't need for internet, but need for connection to client VPN's. Clearly this DUN wasn't needed, since internet is always up (except when I turn the modem off).
    It took me some time to figure out how to make IE no longer popup the DUN, but still make DUN work for the VPN's.

    I'm not the expert on internet related stuff, but I think it's a bit of a catch 22.
    The only way to detect if you REALLY have internet, is to actually open the connection you need to the remote server. Without that, whatever method you try for attempting the connection may get blocked by HTTP proxy or router. (note that ICMP packets are more and more getting blocked).

    And actually opening a connection to a remote server may popup the DUN, you may be able to get around the standard Windows DUN, but not everyone uses that (like me). There are several other connection software packages.
    "temporarily" disabling the DUN by changing the registry as someone suggested won't work for anything but MS' default DUN (and it's a bad idea messing with such registry settings from your code anyway).

    the IE way may be more or less the safest way, but you should provide a way in your code to override the code (providing a 'detect', 'assume never online' & 'assume always online' kind of approach). I know at least 3 programs I can't use at home because they INSIST on starting DUN, and won't run until DUN made a connection to the internet (which it never does, since internet doesn't go over DUN in my case). Tech support of those programs told me to 'deinstall DUN if you have internet over LAN', but that isn't an option because I need DUN. It's very annoying to have software that's this inflexible. (and tech support which is even more rigid)

  3. #63
    Join Date
    Dec 2002
    Posts
    437
    i have made a small utility for checking the connection...........
    Attached Files Attached Files

  4. #64
    Join Date
    Mar 2000
    Location
    Birmingham, England
    Posts
    2,520
    Hey, guess what? ....

    Doesn't work!

    Tells me i am not connected, although i have a connection via dsl modem. I couyldn't find a way to get this to report "connected"

    Jase

    Jase

    www.slideshowdesktop.com
    View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows.
    ...

  5. #65
    Join Date
    Dec 2002
    Posts
    437
    hey even i have a dsl modem and it is working fine ..............i''ll send the debug version which will report the error so we know why is it happening can u pls test it

  6. #66
    Join Date
    Dec 2002
    Posts
    437
    here is the debug version
    Attached Files Attached Files

  7. #67
    Join Date
    Mar 2001
    Location
    India
    Posts
    35

    Detecting an internet connection

    Did anybody try InternetCheckConnection API. Its a straight forward API. And is available with all the OS relevant today.

  8. #68
    Join Date
    Dec 2002
    Posts
    437
    Onkar pls read this post

  9. #69
    Join Date
    Mar 2000
    Location
    Birmingham, England
    Posts
    2,520
    Originally posted by anima_sg
    here is the debug version
    it returns "error not defined" - "not connected".

    I'm on windows XP.

    Jase

    www.slideshowdesktop.com
    View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows.
    ...

  10. #70
    Join Date
    Nov 2003
    Posts
    4

    Question Sources

    Hi anima_sg,

    could you send the sources instead of binaries ?

  11. #71
    Join Date
    Dec 2002
    Posts
    437
    means the error is not defined by the socket.............. i am uploading the code
    Attached Files Attached Files

  12. #72
    Join Date
    Nov 2003
    Posts
    39
    I get the following error when i compile the testconnection:

    tda2Dlg.obj : error LNK2001: unresolved external symbol __imp__InternetGetConnectedState@8

    What do i have to do?

  13. #73
    Join Date
    Mar 2000
    Location
    Birmingham, England
    Posts
    2,520
    You need to add wininet.lib to the link section of the project properties

    Jase

    www.slideshowdesktop.com
    View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows.
    ...

  14. #74
    Join Date
    Nov 2003
    Posts
    39
    Originally posted by jase jennings
    You need to add wininet.lib to the link section of the project properties
    So, did you find the foolproof version of the internet connection detection?

  15. #75
    Join Date
    Mar 2000
    Location
    Birmingham, England
    Posts
    2,520
    I think as perfect an answer as you're gonna get lies in the answers above

    I haven't gotten around to coding it yet due to time demands on another project. When I do, I'll post it. If someone else does it first, I'd really appreciate them sharing it here.

    Thanks guys

    Jase

    www.slideshowdesktop.com
    View your images and photos on your desktop with ease using SlideShow Desktop, the desktop wallpaper manager for Microsoft Windows.
    ...

Page 5 of 8 FirstFirst ... 2345678 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured