Network Interface Detection

Right now I’m working on detecting when network interfaces come and go, so that, for example, Psi can go online when your network connection becomes active. There is a nice debate as to what constitutes a network connection, but I think for our purposes I’ve decided this will be a non-loopback interface bound to a gateway. This code will be part of IrisNet, which is the new network subsystem for Iris.

Time for platform-specific coding fun again.

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

I posted the original Win32 patch (to Remko) for suspend/resume in cutestuff/SystemWatch. The intention was for Psi to disconnect & reconnect on sleep/wakeup.

For some reason the reconnect is commented out at the moment (and from at least the initial Darcs import).

void PsiCon::doSleep()
{
setGlobalStatus(Status("",tr("Computer went to sleep"),0,false));
}

void PsiCon::doWakeup()
{
// TODO: Restore the status from before the log out. Make it an (hidden) option for people with a bad wireless connection.
//setGlobalStatus(Status());
}

BTW: I notice that "michalj" says he's porting SystemWatch to Qt4 and including network status detection. Will this conflict with/replicate what you're doing?

http://forum.psi-im.org/post/24770
http://forum.psi-im.org/post/24811

Norman: I think waking from suspend may be a separate issue, since I don't think the network interfaces actually go down/up during a suspend cycle (or it is OS dependent, at least). Maybe it does go down on your system, and is not back up by the time Psi tries to use it. You should look into it and report back.

James: thanks for the tip

A quick look with Reflector shows me that the interesting stuff happens in :

System.Net.NetworkInformation.NetworkChange::AddressChangeListener.StartHelper()

Have you seen the System.Net.NetworkInformation.NetworkChange class in .NET 2.0?

http://msdn2.microsoft.com/en-us/library/system.ne...

Could be a useful implementation reference (via Reflector).

Does this mean that when you bring your pc out of hibernate that it'll try and login rather than looking at you funny? (A least with pre-0.10, it tried to reconnect)