Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Distributed Applications / January 2005

Tip: Looking for answers? Try searching our database.

Smart Client - connection quality

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dima Semensky - 18 Jan 2005 02:56 GMT
Hi!

I'd like to detect my connection quality. Note, that I'd like to avoid
"ping" solution.

In the Offline block I find very promising code in
WinINetDetectionStrategy.IsConnected
public bool IsConnected()

{

int connectionDescription = 0;

return InternetGetConnectedState(out connectionDescription, 0);

}

connectionDescription is supposed to contain actually what I need - level of
connection quality. I defined the constants:

public const int MinimumPollingIntervalInSeconds = 1;

//Local system uses a modem to connect to the Internet.

public const int INTERNET_CONNECTION_MODEM = 0x1;

//Local system uses a LAN to connect to the Internet.

public const int INTERNET_CONNECTION_LAN = 0x2;

//Local system uses a proxy server to connect to the Internet.

public const int INTERNET_CONNECTION_PROXY = 0x4;

//No longer used.

public const int INTERNET_CONNECTION_MODEM_BUSY = 0x8;

public const int INTERNET_RAS_INSTALLED = 0x10;

public const int INTERNET_CONNECTION_OFFLINE = 0x20;

So here are questions:

1. Can I rely on this value?

2. What would be the best way to implement this in Offline Block?

I'm thinking of extending IConnectionDetectionStrategy or even creating new
interface - something like IConnectionQuality

Thanks,

Dima.
[MSFT] - 19 Jan 2005 05:50 GMT
Dima,

This value can be trusted since it call the low level WINET API
InternetGetConnectedState,

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/win
inet/internetgetconnectedstate.asp

It can tell if a computer is online.

Anyway, if "online" means more, remote server is open or database server is
running, you can implement IConnectionDetectionStrategy to add your
customized logic for detecting online state.

Luke
Dima Semensky - 20 Jan 2005 00:41 GMT
This is clear. What I'm asking is how to detect connection quality?

Can I find out if I'm connected on low badnwidth? At least if I'm on
dial-up, WiFi or wired?

> Dima,
>
[quoted text clipped - 12 lines]
>
> Luke
[MSFT] - 20 Jan 2005 03:21 GMT
InternetGetConnectedState can only detect if it is connected by lan or
modem. For other option, you need to implement your customized code.

Luke
Dima Semensky - 24 Jan 2005 02:15 GMT
Great... I know that... I'm asking what is the best way to do that? Create
new interface? extend existing?

> InternetGetConnectedState can only detect if it is connected by lan or
> modem. For other option, you need to implement your customized code.
>
> Luke
[MSFT] - 24 Jan 2005 06:27 GMT
You don't need to create a new interface. The Offline application block has
define the interface IConnectionDetectionStrategy.  What you need to do is
create a new class, implementing this interface and sepecify your
customized class in the config file.

Luke
Dima Semensky - 25 Jan 2005 13:18 GMT
I looked into that, but when I looked at the provided example, I found that
everything is based on the interface not particular class.

This means I have to implement not just one class but several classes that
are "aware" about connection quality. It would seems to be just natural to
have this in the interface.

> You don't need to create a new interface. The Offline application block
> has
[quoted text clipped - 3 lines]
>
> Luke
[MSFT] - 26 Jan 2005 02:41 GMT
Hello Dima,

You may take a look at an sample in Offline Application Block Quick Start,
named "Conncection Management Quick Start". In its app.config:

<ConnectionManagerProviders>
     <provider name="connectionDetectionStrategy"
              enabled="true"
             
type="Microsoft.ApplicationBlocks.SmartClient.Offline.WinINetDetectionStrate
gy,Microsoft.ApplicationBlocks.SmartClient.Offline.Providers,Version=1.0.0.0
,Culture=neutral,PublicKeyToken=null">
        <pollingInterval>2</pollingInterval>
     </provider>

  </ConnectionManagerProviders>

This specify a class
"Microsoft.ApplicationBlocks.SmartClient.Offline.WinINetDetectionStrategy"
to detect the connection. And here is the definition for this class:

public class WinINetDetectionStrategy : IConnectionDetectionStrategy,
IProvider
    {

..

}

As you see the class  implements IConnectionDetectionStrategy and
IProvider. You need customized detection strategy. you may create a class
intead of this one, which also implements IConnectionDetectionStrategy and
IProvider.

Luke
Dima Semensky - 28 Jan 2005 18:43 GMT
Great. That's what I've done. The problem that the rest of the app works via
IConnectionDetectionStrategy not class instance. So, I either have to extend
the interface or change all rest of the code to pass class instance rather
than interface. First looks much better; the problem with this one is that
other "strategies" that implement the interface will not work anymore.

This is why I'd suggest to update the block to include "connection quality"
functionality as standard feature.

> Hello Dima,
>
[quoted text clipped - 31 lines]
>
> Luke
[MSFT] - 31 Jan 2005 05:26 GMT
It is a great idea for "connection quality". Hopr it can occur in later
version.

Luke

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.