Hello Everybody! I am writing a networking application in python for a small piece of hardware, in which there could sometimes be timeouts. I am using sockets to communicate to this device. Data that is sent to the device is instructions for that piece of hardware, and data recieved is just responses from that hardware. When a timeout happens, for some reason extra data is stored inside the buffer, so when the timeout is over, that extra data (remember this data is instructions) is executed by the hardware, which I don't want. For timeout purposes, I want the socket to be nonblocking, but at the same time this means that I can't flush the buffer, which I think would solve the problem.
I realize this is probably quite unclear, so below is a tcpdump which will explain what I mean. 15:10:37.667963 aurl06f2.39979 > 192.168.128.161.46667: P 481:493(12) ack 481 win 5840 <nop,nop,timestamp 157458905 528016> (DF) 4500 0040 090c 4000 4006 599f 8fd1 06f2 c0a8 80a1 9c2b b64b 30c7 9289 a552 55df 8018 16d0 c3ec 0000 0101 080a 0962 a1d9 0008 0e90 0000 0001 f800 0110 0000 0000 15:10:51.107769 aurl06f2.39979 > 192.168.128.161.46667: P 481:493(12) ack 481 win 5840 <nop,nop,timestamp 157460249 528016> (DF) 4500 0040 090d 4000 4006 599e 8fd1 06f2 c0a8 80a1 9c2b b64b 30c7 9289 a552 55df 8018 16d0 beac 0000 0101 080a 0962 a719 0008 0e90 0000 0001 f800 0110 0000 0000 15:10:51.108259 192.168.128.161.46667 > aurl06f2.39979: P 481:493(12) ack 493 win 5792 <nop,nop,timestamp 533605 157460249> (DF) 4500 0040 5580 4000 3f06 0e2b c0a8 80a1 8fd1 06f2 b64b 9c2b a552 55df 30c7 9295 8018 16a0 dbf5 0000 0101 080a 0008 2465 0962 a719 8000 0001 f800 0110 0000 4d05 15:10:51.108283 aurl06f2.39979 > 192.168.128.161.46667: P 493:565(72) ack 493 win 5840 <nop,nop,timestamp 157460249 533605> (DF) 4500 007c 090e 4000 4006 5961 8fd1 06f2 c0a8 80a1 9c2b b64b 30c7 9295 a552 55eb 8018 16d0 cb29 0000 0101 080a 0962 a719 0008 2465 0000 0001 f800 0110 0000 0000 0000 0001 f800 0110 0000 0000 0000 0001 f800 ************* NOTICE THE EXTRA DATA ***************** 15:10:51.108731 192.168.128.161.46667 > aurl06f2.39979: P 493:505(12) ack 565 win 5792 <nop,nop,timestamp 533605 157460249> (DF) 4500 0040 5581 4000 3f06 0e2a c0a8 80a1 8fd1 06f2 b64b 9c2b a552 55eb 30c7 92dd 8018 16a0 db99 0000 0101 080a 0008 2465 0962 a719 8000 0001 f800 0110 0000 4d0d 15:10:51.111760 aurl06f2.39979 > 192.168.128.161.46667: P 565:577(12) ack 505 win 5840 <nop,nop,timestamp 157460249 533605> (DF) 4500 0040 090f 4000 4006 599c 8fd1 06f2 c0a8 80a1 9c2b b64b 30c7 92dd a552 55f7 8018 16d0 a867 0000 0101 080a 0962 a719 0008 2465 0000 0001 f800 0114 0000 0000 The last 3 words (32 bits/word) of the hex printout shows the condition. The first of the last 3 words is the instruction, in this case a read instruction: 0000_0001. The second is the address: f800_0110 or f800_0114. The third is the data recieved. As you can see, the first 2 printouts are a timeout (it is much longer than this, but i didnt want to post all of that) because one machine is communicating to the other without a response. The third printout is when the machine recovers from the timeout, and it works fine. However, the printout after the machine recovers has some extra data at the end. This is the data I want to flush out of the buffer, but I cant really figure out how to do so. Sorry for the long post and thanks a lot for your help -- http://mail.python.org/mailman/listinfo/python-list