Click to See Complete Forum and Search --> : Problem with CSocket and CArchive


olin
March 8th, 2004, 08:23 PM
I wantted to use CSocket to send and receive data with a HTTP sever. If I wrote it as:

szOut = "GET http://...../ HTTP/1.0\n\n"
m_pSocket->Send(szOut, szOut.GetLength());
m_pSocket->Receive(szIn.GetBuffer(1024), 1024);

It would be no problem and receive a "200 OK" status in szIn.

But if I wrote it as:

CSocketFile SocketFile(m_pSocket);
CArchive arIn(&SocketFile, CArchive::load);
CArchive arOut(&SocketFile, CArchive::store);
arOut << szOut;
arOut.Flush();
arIn >> szIn;

I would receive a "501 Not Implemented" errer status in szIn.

Why this happened?

Thanks!

Andreas Masur
March 9th, 2004, 07:46 AM
[Moved thread]

olin
March 9th, 2004, 09:42 AM
Thank you, But I didn't use multithread. I write these codes in my main thread (the only thread in my application).