socket.error: (9, 'Bad file descriptor')
Fabian Lienert
lienert at mitlinks.ch
Mon Dec 30 02:51:17 EST 2002
You mean the 99999? You are right, but I tested the same thing with port 9999, too.
and port 33063 is ok, because that's the source port, isn't it?
thanks for your patience.
Chris Gonnerman wrote:
> 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
--
Fabian Lienert . mitLinks AG . Limmatstrasse 291 . 8005 Zürich
lienert at mitlinks.ch . ++41 1 444 10 44 . http://www.mitlinks.ch
pgp public key: http://www.mitlinks.ch/keys/lienert.asc
More information about the Python-list
mailing list