trying sockets

Uwe Schmitt uwe at rocksport.de
Tue Oct 2 09:07:16 EDT 2001


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




More information about the Python-list mailing list