trying sockets
Carlos Gaston Alvarez
cgaston at moonqzie.com
Tue Oct 2 09:54:41 EDT 2001
There are http specific classes. Why dont you use them?
Chau,
Gaston
----- Original Message -----
From: "Uwe Schmitt" <uwe at rocksport.de>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Tuesday, October 02, 2001 3:07 PM
Subject: trying sockets
> Hi,
>
> i'm just playing with the socket module: i'd like to send
> a "GET/HTTP" request to a webserver and record the answer
> of the server. so i wrote
>
> from socket import *
>
> snd=socket(AF_INET,SOCK_STREAM)
> snd.connect(("www.num.uni-sb.de",80))
> print snd.getsockname()
>
> lstn=socket(AF_INET,SOCK_STREAM)
> lstn.bind(snd.getsockname())
>
> snd.send("GET / HTTP/1.0 ")
> lsten.listen(1)
> conn,addr=lstn.accept()
> print conn.recv(1024)
>
> lstn.close()
> snd.close()
>
> but i get the following output:
>
> ('134.96.31.42', 1662)
> Traceback (most recent call last):
> File "client.py", line 8, in ?
> lsten.bind(snd.getsockname())
> socket.error: (98, 'Address already in use')
>
> so: what did i do wrong ???
>
> yours, uwe.
>
>
>
> --
> Uwe.Schmitt at num.uni-sb.de Universität des Saarlandes
> phone: +49 (0)681/302-2468 Geb. 36.1, Zi. 4.17, PF 151150
> D-66041 Saarbrücken
> http://www.rocksport.de http://www.rocksport.de/first_ride.mp3
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list