Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What happened to my CRLF?  RSS feed

 
Steven Oliver
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a socket client application that receives XML messages. I have two test clients, one is a c# application and the other c++. To send a message the client first sends the length of the data followed by the specified number of bytes. The problem I'm having occurrs when there are CRLF in the XML message. Everything is fine when the server receives a message from the c# client. When the message comes from the c++ client the CR characters are missing. The correct number of bytes seem to be transmitted because my read loop completes and writes the data into the receive buffer. The problem is that the buffer is left with a number of unused elements, equal to the number of CRLF in the source message, at the end of the buffer.

Any thoughts on what happened to my CRs?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just that the C++ client is improperly written, I suppose; it's sending LF instead of CRLF.
 
Steven Oliver
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought that could be the case too. The client sends the message length first and that value includes the CR character. For example when sending

<test></test>

the message length is 13. When sending

<test>
</test>

the message length is 15 so both the CR and LF are getting counted by the client. The server loops until all bytes are received so it would not complete unless it read 15 bytes. But only 14 bytes end up in the intput buffer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!