Results 1 to 5 of 5

Thread: [RESOLVED] Can I check the connection status?

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Resolved [RESOLVED] Can I check the connection status?

    Hi,
    I want to check the PocketPC whether connection or not...

    if the PocketPC can connect to the internet, then the application can be run..
    if the pocketpc status is offline, then I enable the user switch on the wifi function!!

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Can I check the connection status?

    if you want to check for an internet connection you will have to try a http request

    if you want to check for a network connection you will have to check the device's ip address. (if the ip address is not 127.0.0.1 then its connected to a network via activesync or wireless)
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: Can I check the connection status?

    Quote Originally Posted by Strider
    if you want to check for an internet connection you will have to try a http request

    if you want to check for a network connection you will have to check the device's ip address. (if the ip address is not 127.0.0.1 then its connected to a network via activesync or wireless)
    Thanks..
    but can you give me more hints!!

    which method I can use in httprequest!!

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Can I check the connection status?

    Hi,
    httpRequest...

    VB Code:
    1. Dim Response As WebResponse
    2.         Dim ResponseStream As Stream
    3.         Dim Request As WebRequest
    4.         Connect_To_Server = True
    5.         Try
    6.             Request = WebRequest.Create("http://www.google.com")
    7.             Response = Request.GetResponse
    8.         Catch webex As WebException
    9.             Connect_To_Server = False
    10.         Catch ex As Exception
    11.             Connect_To_Server = False
    12.         Finally
    13.             Cursor.Current = Cursors.Default
    14.             If Not IsNothing(Response) Then
    15.                 Response.Close()
    16.             End If
    17.         End Try

    Connected...
    VB Code:
    1. Dim localEndPoint As New IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList(0), 0)
    2.         If localEndPoint.Address.ToString <> "127.0.0.1" Then
    3.             Connected = False
    4.         End If

    Pete

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2005
    Posts
    56

    Re: Can I check the connection status?

    Quote Originally Posted by petevick
    Hi,
    httpRequest...

    VB Code:
    1. Dim Response As WebResponse
    2.         Dim ResponseStream As Stream
    3.         Dim Request As WebRequest
    4.         Connect_To_Server = True
    5.         Try
    6.             Request = WebRequest.Create("http://www.google.com")
    7.             Response = Request.GetResponse
    8.         Catch webex As WebException
    9.             Connect_To_Server = False
    10.         Catch ex As Exception
    11.             Connect_To_Server = False
    12.         Finally
    13.             Cursor.Current = Cursors.Default
    14.             If Not IsNothing(Response) Then
    15.                 Response.Close()
    16.             End If
    17.         End Try

    Connected...
    VB Code:
    1. Dim localEndPoint As New IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList(0), 0)
    2.         If localEndPoint.Address.ToString <> "127.0.0.1" Then
    3.             Connected = False
    4.         End If

    Pete

    it works well!!

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