Ok all you need-
1. Configure web browser to connect internet through your program. If you are using internet explorer then Goto tools internet option Connection LAN setting check "use a proxy for your LAN and put 127.0.0.1; in place of Address: and 8080 (or whatever you want) as port no. After this when you click on any link or go to any address then your browser will attempt to make a connect on IP:PORT you configured.
2. Create a server socket and start listening on port 8080 (or what ever you configured). Accept connect from web browser and read all data from client socket (It is data sent by web browser), now you have a HTTP request. for reading this 4k buffer is sufficient.
3. Now parse this request and get the value of HOST: header it must look like "Host: www.google.co.in" (read HTTP specification for the HTTP request format). Hint for parse it look for the index of ;host:" or "Host:" or "HOST:" and copy data starting from Host: and till the "\r\n". Trim the content.
And now you got the desired host name.
4. Now you have 2 cases
A. This host name is in your block list.
What to do :-Take these lines into a buffer
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="5;url=http://www.codeproject.com"></meta></head>
Optional page text here.
This site is blocked and you are redirecting to
www.codeproject.com in 5 seconds
and write that buffer to the client socket (socket for browser). Now browser will redirect page to www.codeproject.com in 5 seconds.
B. This host name is in your block list.
What to do :- create a client TCP socket connect to the host which you just parsed write the HTTP request to it and read the response. now write this response to the socket for web browser and browser will render the page.
If you found any difficulty to understand or implement it feel free to ask and once you write basic program then i will tell you about some design related optimization