1. easy(?) MFC CSocket question
I am attempting to set up a proxy HTTP server using the Microsoft
Foundation Class programming model for Windows Sockets. The client
sets up their browser to send their HTTP request packet to the local
host (127.0.0.1) on an arbitrarily chosen port 2742. My proxy listens
to 2742 and intercepts this request. Everything works up to this
point. My proxy then sends the request on to the web server specified
in the request... but when the proxy tries to intercept the web
server's reply, it's execution seems to get lost somewhere in the
CSocket code. Here is my "FetchReply" function source code:
CString FetchReply(CString Request)
int HostAddressPos, HostAddressEndPos;
//First I extract the host name from the GET request I have already
//successfully intercepted from the browser and passed to this function
//via the "Request" CString parameter
HostAddressPos = Request.Find("Host: "); // The host name is contained
//in the request on a "Host: " line, i.e.: "Host: www.thehost.com"
HostAddressPos+=6; // Forward to the beginning of the actual address
//(past the "Host: ")
HostAddressEndPos = Request.Find( '\n', HostAddressPos ); // Find the
// end of the line
HostAddress = Request.Mid( HostAddressPos, (HostAddressEndPos -
HostAddressPos - 1) ); // Extract the address - an extra -1 since I
//don't want the '\n'
CSocket cliSock; // Client socket (will request and retrieve from the
cliSock.Create( 2743 )
// Will create the client socket on 2743 (arbitrarily chosen)
cliSock.Connect( (LPCTSTR)HostAddress, 80 ))
// Port 80 is the standard HTTP server port
CSocketFile cliSockFile( &cliSock );
// Client reciever Socket File
CArchive cliSockArchive( &cliSockFile, CArchive::load );
// Reciever Socket Archive
CArchive cliSockSendArchive( &cliSockFile, CArchive::store );
// Sender Socket Archive
cliSockSendArchive << Request; // This seems to work fine
cliSockArchive >> Reply; // Execution does not make it past this line
I do not get any assertion failures or any error messages of any kind -
my proxy just sits there, and if I wait long enough, the browser times
I've tried to follow the CSocket/CSocketFile/CArchive specifications as
closely as possible, but I must be missing something. Why am I not
getting any reply?
Sent via Deja.com http://www.deja.com/
Before you buy.
2. Want to buy old systems but no idea what to pay ...
3. CSocket::CancelBlockingCall() question
4. Instruction Scheduling
5. MFC CSocket Nagling Question
6. Terminal to replace keyboard/monitor?
7. CSocket Create Generate C++ Exeception?
8. Job Scheduler?
9. My CSocket::Send() blocks for over 60 seconds on some computers
11. DLL freezes after calling CSocket.connect(...)
12. CSocket::Receive in a static method