KExtendedSocket readLine behaviour

Rob Kaper cap at capsi.com
Mon Jul 22 14:52:21 BST 2002


I noticed that KExtendedSocket's readLine behaviour is far from perfect, it
seems to lose data.

I use the following code:

if (canReadLine())
{
  char *tmp = new char[1024 * 32];
  readLine(tmp, 1024 * 32);
  processMsg(tmp);
  delete[] tmp;

  // There might be more data
  QTimer::singleShot(0, this, SLOT(slotRead()));
}

All too often I get some parsing errors in processMsg, complaining that the
data I fed into it is not a valid XML document (I don't allow the use of
newlines in messages in my protocol, they are the delimiters between XML
documents).Instead of

<monopd><playerupdate playerid="1" name="Rob"/></monopd>

processMsg seems to get

<playerupdate playerid="1" name="Rob"/></monopd>

which will never validate or parse. While the missing "<monopd>" is sent
seperately, it is not terminated with a newline (I've checked), so I have no
idea why it is missing from the message to be processed.

I do *not* get a warning that "<monopd>" is invalid, so it looks like the
problem is not that canReadLine returns true for that string. It is however
lost somewhere before the rest of the data arrives.

I do have some flush() code, but that is only triggered when there is > 32kB
of data without newline which is definitely not the case here, unless
bytesAvailable is still very buggy.

Rob
-- 
Rob Kaper     | Gimme some love, gimme some skin,
cap at capsi.com | if we ain't got that then we ain't got much
www.capsi.com | and we ain't got nothing, nothing! -- "Nothing" by A




More information about the kde-core-devel mailing list