too many msgs (unknown source)

Hi All,

I have a problem that I don't know its source. I got a client - server application (one client only) over TCP. I use berkley socket architecture (i.e. select). I log every msg ID that each side recv/ send. the problem is that each side accept more msgs that I actually send, so that all the data that I send is recieved by both sides but between the 'correct' msgs each side accept 'empty msgs'. I indexed each msgs IDs starting from 100 and on, and the log file do contain all of them but also empty msgs (ID = 0). the log file looks like that:

100
0
101
0
0
102
0

etc.

do anyone knows what could be the reason? I checked the buffer state over the 'wrong msgs' and noticed all cells in buffer contains only '0'. also found out that on these cases bytesCounter equals MSG_LEN, so it looks like some wiered msg is somehow received.

I also checked the send function and noticed it's never being called with any msg whos ID is less than 100 (so it can't explain the ID '0').

in my encode string function (client and server are multi OS so I encode/ decode string) I put '\0' in the end of array. could that be the reason?

any other ideas?
thanks.