Nowadays I want to make a local proxy using socket.
Btw, how we can determining whether the received buffer is a HTTP header / content file?
Nowadays I want to make a local proxy using socket.
Btw, how we can determining whether the received buffer is a HTTP header / content file?
If you understand how HTTP works it would be very clear. Note that you'll actually need to understand HTTP in great depth to make a proxy server (at least one that follows the HTTP standards) -- see the RFC.
Yeah, thank you zacs7.
Btw the structure of HTTP connection is:
Well, I discovered that internet/network programming is so interesting.Code:Request header: header + "\r\n" Response header: header + "\r\n" + content (if any)
It's complex but standarized.
But I just get confused when different browser sends different thing of request.
For example:
From http:// username : password @ server
typed in address bar.
Firefox sent:
Opera sent:Code:GET http://server/ HTTP/1.1 Host: http://server
Also they act different when we are inputting https:// address.Code:GET http://server/ HTTP/1.1 Host: http://server:80 (extra useful? port) Authentication: Basic aaBBccDDee (plus this)
Btw, they said C is for network programming. But where is the std* API for network?
Should I use WSA* API in Windows?
Last edited by audinue; 08-01-2008 at 09:28 AM.
Sockets is the "standard" for TCP/IP network programming, which is the basis of the Internet. See Beej's Guide for a nice tutorial for programming sockets.
Yes, the WSA* stuff is Winsock, the Windows Sockets API. Here's how to do a basic Winsock app.
Wow, your reply is very-very help me rags_to_riches...
Thank you.
Btw I think "standard" is something like stdlib.h, stdio.h, time.h that provided portability and included in every C compilers ^_^ ...
Notes:
I found that Internet Explorer doesn't suport proxies for FTP protocols.
Last edited by audinue; 08-01-2008 at 12:05 PM.
There is no support for network programming in the C standard library. On the other hand, sockets programming is at least a de facto standard.Btw I think "standard" is something like stdlib.h, stdio.h, time.h that provided portability and included in every C compilers ^_^ ...
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
C and UNIX were developed together. BSD sockets was developed on BSD (I think) UNIX. Therefore, you can see how sockets and C go together.
It's ok I think I will go search something like cygwin to make a portable local proxy...
Btw, guys, I have a problem about receiving and sending request andresponse header in my proxy...
1. A client sends a raw request header to the serverProxy(a socket).Code:client -> serverProxy -> clientProxy -> server -> clientProxy -> serverProxy -> client
2. The proxy translate them into web request header then send it to the server via clientProxy(a socket).
3. The clientProxy get the response header and the content. The proxy synchronizing it with serverProxy.
4. The serverProxy send the response header and the content to the browser.
...
My questions
In step 2, any tips for translating raw to web request header?
In step 4, do we need to do something with response header in step 4?
And ...
What is the advantages/disadvantages of blocking and non-blocking connection in socket?
Hey, I found a clear and simple Socket tutorial:
http://www.nullterminator.net/winsock.html