I was writing something several years ago where I wanted to know the
same thing, and in the end I gave up on the idea of offline/online
because there is no clear definition. Does it mean an active ethernet
connection? or a valid functioning TCP/IP stack? or can I get to a
particular IP address? or a successful DNS lookup? And then, even if all
those are true at this moment, what about on the next TCP/IP request or
the one after that? After alot of research and discussion with
colleagues, I discarded the idea and just used the built in timeouts in
all socket calls. In a way it kind of sucks because your code appears to
"lock up" if they have no connection whatsoever but I didn't see any
better option. One thing you'll note is that on Windows, there doesn't
seem to be a better way either because how many systems have you seen
popup the RAS connection stuff when a particular TCP/IP request fails
even though the machine does have a functioning connection.
So, my round about answer is, I don't think there is a way.
Adam Judson wrote:
Why do you want to test for this?
Do you really want to know if they can see site X? I can have a live
connection but if my proxy fails etc. I effectively don't...
I wonder if you are trying to solve the right problem.
Adam
On 14/04/06, Brian King <[EMAIL PROTECTED]> wrote:
What is the best way for an extension to detect if a user is
online/offline? I'm not talking about, for example, the Work Offline
feature in Firefox, but rather about whether they have an internet
connection at the time a particular piece of code is executing.
Thanks,
--
Brian King
www.mozdev.org - free project hosting for the Mozilla community
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners