Click here to Skip to main content
15,919,879 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am re-writing an application (A) that communicates with another application (B) via sockets on another machine. Application B is written in MFC and contains the CArchive class.

Now, I don't understand a lot about the B code yet, but an odd thing I have noticed is that when a message gets sent from A to B, it eventually gets sent to the CArchive::ReadString method. If this message is an array of character with a size that is a multiple of 128 it works fine - the OnReceive method gets called for each group of 128 characters and each set of 128 chars is sent to CArchive::ReadString which completes and returns happilly. However, if there is a remainder ie an array of chars which is less that 128 is passed to ReadString, then ReadString gets stuck and the system hangs.

Is there anyone who can shed some light on this please?
Posted

1 solution

In the MSDN Help I found this...

In the version of the member function with the nMax parameter, the buffer will hold up to a limit of nMax - 1 characters. Reading is stopped by a carriage return-linefeed pair. Trailing newline characters are always removed. A null character ('\0') is appended in either case.

CArchive::Read is also available for text-mode input, but it does not terminate on a carriage return-linefeed pair.


In the mode that you have it opened for, it may be waiting on a carriage return line feed pair. This is the default behavior for Telnet. In this mode, it's expecting the user to hit the return key, before processing the command.
 
Share this answer
 
Comments
Jackie Lloyd 29-Feb-12 3:36am    
Thank you very much for pointing that out - that must be the problem :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900