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

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Sun Dec 29 10:11:51 EST 2002


Port numbers are two-byte unsigned integers; 65535 is the
largest allowed.  I'm not sure what your program is doing
with that invalid port number, but I'm sure it isn't right.

Chris Gonnerman -- chris.gonnerman at newcenturycomputers.net
http://newcenturycomputers.net


----- Original Message -----
From: "Fabian Lienert" <fabian at mitlinks.ch>
To: <python-list at python.org>
Sent: Sunday, December 29, 2002 9:03 AM
Subject: socket.error: (9, 'Bad file descriptor')


> Dear python group members,
>
> While I am learning python I face the following problem:
>
> I experienced with socket module. what i want is that a socket listens on
a port
> and prints something on request.
>
> so i can start my socket that listens to port 99999. i can connect with
"nc localhost
> 99999", write "cpuload" and press enter. my little program gives me the
right string back.
> but the python interpreter says:
> --
> Connected by ('127.0.0.1', 33063)
> Traceback (most recent call last):
>    File "<stdin>", line 9, in ?
> socket.error: (9, 'Bad file descriptor')
> --
>
> this comes from emacs python C-c C-c executing.
> from shell i get:
> --
> # python2.2 python/socket5.py
> Connected by ('127.0.0.1', 33064)
> Traceback (most recent call last):
>    File "python/socket5.py", line 9, in ?
>      data = conn.recv(1024)
> socket.error: (9, 'Bad file descriptor')
> --
>
> my python script:
> --
> 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()
> --
> thanks a lot for any help in advance!
> fabian
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>





More information about the Python-list mailing list