Hello, I'm using Python's asynchat module for network support in a Python-based game, and I run into two problems, both of which occur at random times. Most of the time, the network sending and receiving is perfect, but about 1 out of 10 times, it fails with one of these errors:
-- Problem 1. When sending data, I sometimes the following exception: Handler connected 127.0.0.1:1242 at 0x2977800> (socket.error:(9, 'Bad file descriptor') [C:\Python24\lib\asynchat.py|initiate_send|219] [C:\Python24\lib\asyncore.py|send|332] [C:\Python24\lib\socket.py|_dummy|144]) -- Problem 2. Receiving data on the client is not always the same size as the data which is sent from the server. Network server is found here http://svn.gna.org/viewcvs/openrts/trunk/openrts/client/networkclient.py?rev=39&view=markup Network client is found here: http://svn.gna.org/viewcvs/openrts/trunk/openrts/server/clienthandler.py?rev=41&view=markup This is the sequence for sending data: 1. In clienthandler.py the method send_to_client() is called with whatever data should be sent to the client. 2. send_to_client() compresses the data, and passes it to the push() method of asynchat. 3. Client receives the data, and called found_terminator() in networkclient.py 4. In the found_terminator() method, the data is attempted to be uncompressed, but it failes, since the received data does not have the same size as the data which is sent. Sometimes, the difference in size is often 512 between client and server, when running len(packet) on the *compressed* packed. The len() of a large packet is usually about 64969. Complete source code is available at http://svn.gna.org/daily/openrts-snapshot.tar.gz Thanks anyone for the help, - Andreas R. www.openrts.org -- http://mail.python.org/mailman/listinfo/python-list