On Wednesday, July 30, 2003, at 01:05 PM, Eric Peden wrote:
Currently, I simply "get URL" a page on our web server and, if the result
is empty, show the "not connected" message. However, this has a couple
of problems:
1) There's often a significant timeout delay when the network is
unavailable, sometimes 10 or 15 seconds. I'd like to let the user know
more quickly what the problem is.
This can be 75 seconds on OS X and 21 seconds on W2K and XP.
2) I can't distinguish between a "no network" error and a timeout error.
Ideally, I'd let the user know the problem is not their fault if I
get a timeout, but since I'm also relying on a timeout to tell me if
the network is not available, I can't provide a specific error
message.
I could fix (1) by opening a socket with a shorter timeout value, but that still doesn't address (2). Any ideas?
Your idea of simply opening a socket rather than 'get URL' is a better way to go. The socketTimeout does not apply to open, so you will have to chase after it with a send to cancel the open (close) and declare a timeout. If you are using a blocking style (not using 'with message') there still might be a way.
For #2, you can provide a generic error message "Cannot connect to Eric's server!" I know this doesn't address your desire, but it might be the only way to go. Another approach is to add a step that (among other things, perhaps) instructs the user to make sure the computer is connected to the Internet. That can avoid any surprise dialing problems.
Part of the problem is what "no network" means. Does it mean the user did not dial up the ISP? Does it mean the cable to the Ethernet card is not connected? Would it apply to the case where the user is connected to the local LAN but the gateway to the Internet is down? Does it mean that TCP/IP is not even set up on the computer? To detect that a computer can reach the internet whether or not the LAN is up requires trying to.
You can check result() on the open. That can catch a lot of local problems.
If you mean access to the Internet, then one method is to open a tcp link to a reliable related Internet computer by IP address and then close that. If there is a chance the client is behind a firewall, it may need to be port 80. Maybe the user can set up an address or name that can be used for checking this.
You might explore a couple ideas related to DNS. If DNSServers() returns empty, then the computer is not connected to the Internet, but if not then you don't know. You might try a query with hostNameToAddress(), but that might be cached, either on the local computer on on a LAN DNS server. _If_ DNSServers() returns a public IP Address, you can try to open DNS with tcp, however, some locations limit DNS to udp. You might opening to _your_ DNS sever.
You might try ping with shell().
If your server computer is up, but the service is down, then the open will be refused. If you use 'with message' you will get a socketError callback on Windows and a socketClose on OS X. I think you also get it without the 'with message'; I so rarely use blocking I/O, I don't remember. You can use that as a distinction. Windows will delay this for 9 seconds.
Dar Scott
_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution
