socket.error: (9, 'Bad file descriptor')

Fabian Lienert lienert at mitlinks.ch
Mon Dec 30 14:40:11 EST 2002


Am Mon, 30 Dec 2002 11:10:59 +0000
tippte Pedro Rodriguez <pedro_rodriguez at club-internet.fr> folgendes:

> On Sun, 29 Dec 2002 15:03:42 +0000, Fabian Lienert wrote:
> 
> > --
> > import socket
> > 
> > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > s.bind(('localhost', 99999))
> > s.listen(1)
> > conn, addr = s.accept()
> > print 'Connected by', addr
> > while 1:
> >      data = conn.recv(1024)
> >      if not data: break
> >      elif data == 'cpuload\n' or data == 'cpuload' :
> >          conn.send("Hier die CPU Aktivitaet:\n")
> > #    conn.send(data + "\n")
> >      conn.close()
>        ^^^^^^^^^^^^
> 
> You are closing the socket too soon !!!
> This line should be 'dedented' and be put at the same level
> than the 'while'.
> 
> BTW, I don't think using a port above 65535 is recommended.
> Have a look at 'netstat -a', and you'll noticed that your
> port number as been 'reduced' to 16 bits.
> 
> Pedro

great, that helped, thanks Pedro.

fabian




More information about the Python-list mailing list