"wormwood_3" <[EMAIL PROTECTED]> wrote

> Have not gotten any responses on this,

I did send you a response and it is listed on the gmane archive
so if you didn't see it something has gone adrift somewhere.

> But, I did find a decent recipe on ASPN that serves the purpose,

The solution you posted seems to bear no resemblence
to the problem you posted? How does this relate to setting
socket timeouts or using getfqdn()?

This solution simply does a ping on a site to see if the
network is available. If you had asked how to check if you were
connected to the network you likely would have gotten
several responses!

As ever, if you ask the wrong question you will get the
wrong answer! :-)


> def checkURL(url):
>    """For checking internet connection. Taken from recipe:
>    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/101276""";
>    try:
>        p = urlparse(url)
>        h = HTTP(p[1])
>        h.putrequest('HEAD', p[2])
>        h.endheaders()
>        if h.getreply()[0] == 200: return 1
>        else: return 0
>    except:
>        return 0
>
> The nice thing about this check is that is just looks at the head of 
> the site, and so is rather fast.

> I am trying to figure out the optimal way to make socket connections
> (INET) and check for timeouts. The socket module has 
> settimeout(timeout)
> and setdefaulttimeout(timeout). However, so far as I can tell, these
> apply to socket objects. The type of socket connection I want to
> make is getfqdn(address). So I can set the default timeout for 
> socket,
> but not a socket object (makes sense so far). I cannot use the
> getfqdn(address) method on a socket object, I have to use it on
> socket. This means (as I understand it thus far), that while I can
> set a timeout value for socket objects, this will not apply to when
> I use the getfqdn() method, which is where I need a timeout check!


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to