realbasic-nug
[Top] [All Lists]

Re: Socket that doesn't lock up when Internet connection is down?

To: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Subject: Re: Socket that doesn't lock up when Internet connection is down?
From: Carlos M <rblists@rbtips.com>
Date: Tue, 30 Jun 2009 04:39:09 +0100
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com; dkim=neutral (body hash did not verify) header.i=@gmail.com
Delivered-to: listarchive@realsoftware.com
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=ZH8vmTU8oaPoWZi8lufp+pCJXKlCGUU2So60RDaGOCc=; b=XTmHB1YqV8GjDxRoW5sEVijYvgy552uLHUet+jzGsAZay5UfTVPCExP1NQYzF4whJw XBy2BYUm8WYWYORztqrAFmoDn3JhwCwQsX+03XMNMV7G/utSCMi8CDB7iPFbDivwRt3t cBHiVZP3vStImMseznF69Wa9jA2XnfvYN5TlM=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=OZudx1/yWAWHOg5v2Ta6bDoI2BjeLMobi3gPW5PYt3GY8WNHDzecSQ3Ro3466dcET7 pv8T+f9XQI+LinC8Xy7wsaI4afzFnzvbLcOdQFsRZz2kInrQYA8zWyR8//h9lDkJZ/aI IOmRIg+8ne2z7kT4kiTxJfeLKgQLwd16ZJUSg=
In-reply-to: <fed2e2560906291915l781ce993r8f4845c277426d25@mail.gmail.com>
References: <fed2e2560906271929i1652ef0er8785ef1a5178fd8e@mail.gmail.com> <563B7A44-1E04-4647-AA9A-21C3AB8B2D38@bainsware.com> <fed2e2560906272224jb7fdacby106dbec8f16a8759@mail.gmail.com> <C3D61FD9-93C0-4475-9543-129005597DC7@monkeybreadsoftware.de> <fed2e2560906280922x11a2d54dgcdeef6e48e98e36b@mail.gmail.com> <4a533bec0906290140m49f69e57q2151f4ed89692de0@mail.gmail.com> <fed2e2560906291915l781ce993r8f4845c277426d25@mail.gmail.com>
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
On Tue, Jun 30, 2009 at 3:15 AM, Dennis Birch<dennisbirch@gmail.com> wrote:
> On Mon, Jun 29, 2009 at 1:40 AM, Carlos M<rblists@rbtips.com> wrote:
>
>> For Windows check the WFS InternetConnection module:
>> http://aaronballman.com/programming/REALbasic/Win32FunctionalitySuite.php
>
> Thanks for the tip, Carlos. I put together a test project and ran it
> in Windows 7 beta which is installed in VirtualBox on my iMac.
>
> I get the exact same values for each of the following module tests
> with the DSL modem plugged into the switch and removed from the
> switch:
>
>    dim offline As Boolean = InternetConnection.Offline
>    dim configured As Boolean = InternetConnection.Configured
>    dim lan As Boolean = InternetConnection.LAN
>    dim noconnection As Boolean = InternetConnection.NoConnection
>    dim modem As Boolean = InternetConnection.Modem
>    dim busy As Boolean = InternetConnection.ModemBusy
>    dim proxy As Boolean = InternetConnection.Proxy
>
> Have I overlooked something, does it not work the same in a virtual
> machine as in a real PC, is it Windows 7, or what?

I'm using only Windows, so I can't help you with this. On Windows XP
it works fine.

Anyway, here's a function that I added to that module that might help
you. It allows to check if a connection to internet can be made by
using a url.

InternetCheckConnection Function
http://msdn.microsoft.com/en-us/library/aa384346(VS.85).aspx

Function HostReacheable(url As String, forceConnection As Boolean =
False) As Boolean
  // Returns if a connection to a host (using an URL) can be established
  // Note: If forceConnection is True it will try to force a connection and if
  //       there's a firewall an alert might be displayed

  #if TargetWin32

    // FLAG_ICC_FORCE_CONNECTION = &H1

    Soft Declare Function InternetCheckConnectionA Lib "Wininet" _
    ( lpszUrl As CString, dwFlags As Integer, dwReserved As Integer ) As Boolean
    // On 2005r4 and Windows XP the Unicode version DOES NOT WORK
    // Didn't try to figure why... so I'm using the ANSI version
    'Soft Declare Function InternetCheckConnectionW Lib "Wininet" _
    '( lpszUrl As CString, dwFlags As Integer, dwReserved As Integer )
As Boolean

    Dim b As Boolean

    If System.IsFunctionAvailable( "InternetCheckConnectionA", "Wininet" ) Then
      If forceConnection Then
        b = InternetCheckConnectionA( url, &h1, 0 )
      Else
        b = InternetCheckConnectionA( url, 0, 0 )
      End if
    End If

    Return b

  #endif
End Function


Carlos

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>