timeout and sockets example request??
Ishwar Rattan
rattan at cps.cmich.edu
Fri Jul 23 15:26:38 EDT 2004
Dave Brueck <dave at pythonapocrypha.com> wrote in message news:<mailman.724.1090525178.5135.python-list at python.org>...
> Ishwar Rattan wrote:
> What version of Python are you using? Could you post some code showing
> what didn't work? Here's why I ask:
>
> Python 2.3.4 (#53, May 25 2004, 21:17:02)...
> Type "help", "copyright", "credits" or "l...
> >>> from socket import *
> >>> s = socket(AF_INET, SOCK_STREAM)
> >>> s.settimeout(5)
> >>>
>
> (no errors)
>
> setdefaulttimeout is handy when you don't have access to the actual
> socket object, e.g.:
>
> >>> import socket
> >>> socket.getdefaulttimeout()
> 10.0
> >>> socket.setdefaulttimeout(3)
> >>> import urllib
> >>> urllib.urlopen('http://www.google.com').read()
> '<html><head><meta http-equiv="content-type" content=...
>
> -Dave
Thanks for the example. It comes out that I ws running python-2.2.3 :-(
-ishwar
More information about the Python-list
mailing list