I havn't used CSocket class, but I created two MFC dialog projects (supports sockets), one server and the other client, pasted your code into them, used my own IP address, and got the same behavior. Used VC++ 6.0 with SP 5 on XP Pro computer.
Printable View
I havn't used CSocket class, but I created two MFC dialog projects (supports sockets), one server and the other client, pasted your code into them, used my own IP address, and got the same behavior. Used VC++ 6.0 with SP 5 on XP Pro computer.
CArchive needs one of the '\n' and '\r' characters at the and of the string, try this it will works
//Client side
ArchiveSending.WriteString("GiveMeData\n");
//Server side
ArchiveSending.WriteString("Data\n");
Aliteke2004,
Regarding your note about appending \r\n to the end of strings sent with CArchive::WriteString, yes, you are correct. The sample code I included with my posting was a very stripped down version. My actual code includes a derived class for CArchive and my derived WriteString automatically appends the \r\n. When I "cleaned up the code" to make it simpler for posting I failed to add the \r\n in the calls themselves.
Thus, the lack of \r\n is not really the problem. The symptoms that I described do in deed occur on a random basis. The CSocket class does indeed "lock up" inside its Connect method.
- Roger