April 9th, 2012
(written by lawrence, however indented passages are often quotes)
I’m going to try to write my own chat software soon. This is part of my research. I’m thinking a lot about how much I should try to handle in my own code and how much I should rely on the functionality that is already there in Unix systems.
For most modern platforms you have some sort of basic socket layer available based on BSD sockets.
BSD sockets are manipulated using simple functions like “socket”, “bind”, “sendto” and “recvfrom”. You can of course work directly with these functions if you wish, but it becomes difficult to keep your code platform independent because each platform is slightly different.
So although I will first show you BSD socket example code to demonstrate basic socket usage, we won’t be using BSD sockets directly for long. Instead, once we’ve covered all basic socket functionality we’ll abstract everything away into a set of classes, making it easy to you to write platform independent socket code.