Friday, May 18, 2012

Welcome to the machine...

So this is my first post on my new blog. I have had a couple of these where I have posted what I have been working on in the past, always having them hosted privately with funding. This time I have decided to go with Google's Blogger service. I spent just a little time customizing a template to my liking. Everything has to be dark as sunglasses at night.

Anyway, I have been working intensely since summer began a week or so ago on building up my knowledge of network programming (before I started I practically had none). I have learned all about the network stack that most servers have and read up on networking basics and communication protocols. I found some fantastic websites and guides. For anyone interested in this type of thing I highly recommend checking out these when you get time:

Beej's Guide to Network Programming (Sockets)
HTTP Made Really Easy

Both of these are great written guides and you are sure to learn a ton if you haven't had the joy of reading them yet. Anyways.. I read both of those back to front, err... front to.. kind of both ways actually. Earlier this past semester I got to wondering about how much work goes into a modern browser and I read another article which is very informative as well.

How Modern Browsers Work

After I learned a good bit about sockets and got in good with the Winsock2 API. I created a nice program that would take a hostname, use the API to tap into DNS to resolve the hostname to an IP address. At that point the program connect to server on port 80 (default for HTTP protocol) and sends a request to the server.

HTTP requests come in a few forms. You can send a HEAD request which returns a response that basically tells you what kind of content you will receive if you go to that address. My program used a GET request in order to pull the HTML (or other data) from the default page at the given hostname's address. I'm not sure if you can see where this is going, but basically this program is already part of what a browser does. All that is left really is to be able to render HTML.

I am now working with a cross-platform GUI library that is actually capable of rendering a DOM tree (this is what HTML is parsed into). I am now working on a basic text based browser. I plan on making a tutorial or guide when I am finished. The library is called wxWidgets and I mostly chose it for being open-source (my favorite), cross-platform, native C++, and mostly for the ability to render the HTML DOM tree.

Here is a screenshot of the GUI I threw together with a add-on tool called wxFormBuilder:

And here is a screenshot of the console program using sockets and http to pull the html data from a simple test site I set up:


Cory Gross said...

This is a test comment for development/testing purposes.

Post a Comment