Results 1 to 4 of 4

Thread: [2005] Check if computer is online.

  1. #1

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    [2005] Check if computer is online.

    What's the fastest way to figure out if the computer your application is running on is connected to the internet? Also, what's the easiest way to download a file ? Thanks.

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] Check if computer is online.

    Quote Originally Posted by Nove
    What's the fastest way to figure out if the computer your application is running on is connected to the internet?
    I could have sworn someone said VB 2005 had an event that would fire if an internet connection changed state (like got disconnected or connected) but I can't find any information on it. Maybe I was just going crazy?

    Anyway, there isn't an easy way to do this. You could attempt to ping a computer or website, but many corporate environments and web servers will block pings so it won't be accurate. Same with attempting to access a specific website via HTTP or HTTPS as websites are not guarenteed to be there and many corporate environments block certain websites or HTTP entirely (or HTTPS).

    I have yet to see an accurate way to always tell when you are connected or not, You could check the current IP address and parse it to see what kind of network it's on but there could be internet problems so that also wouldn't be accurate.

    Quote Originally Posted by Nove
    Also, what's the easiest way to download a file ?
    Using a WebClient.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] Check if computer is online.

    You aren't going crazy kas. The My.Computer.Network.IsAvailable property will tell you at any time whether you have an available network connection and the NetworkAvailabilityChanged application event is raised whenever that state changes. Note that this is network availability. If you are connected to a wired or wireless network that is not itself connected to the Internet this will still indicate that the network is available. Also, I'm not sure whether a dialup modem connected to the Internet qualifies as a network connection or not.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2005] Check if computer is online.

    Quote Originally Posted by jmcilhinney
    You aren't going crazy kas. The My.Computer.Network.IsAvailable property will tell you at any time whether you have an available network connection and the NetworkAvailabilityChanged application event is raised whenever that state changes.
    Yay, I'm sane!

    Though, parsing your IP would tell you the samething.

    There are just too many factors in trying to determine if your computer is online or not so it may just not be possible.
    Quote Originally Posted by jmcilhinney
    Also, I'm not sure whether a dialup modem connected to the Internet qualifies as a network connection or not.
    I would imagine it would as that is still a network connection and you're still getting an IP address, it's just another means to get it.

    Though I have no way to test that theory.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

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