ABSTRACT

This section is going to use C++ code. The syntax for C++ is very similar to the JavaScript syntax you are familiar with from using Flash ActionScript. We are going to use something called Microsoft Foundation Classes. This is a library of C++ classes (another word for objects) that make programming Windows applications easier and more robust. To make use of the example on the CD, you will need a copy of Visual C++ on a PC. If you can, open the file ‘Examples\Chapter22\ SockListener\SockListener.dsw’. This file is a Visual C++ project file. A C++ project uses several files to store the source code and other information required by the IDE (Integrated Development Environment) to compile the program. The source we will examine is in the file ‘SockListenerDlg.cpp’, which is simply a text file; so if you don’t have Visual C++ then just open this in a text viewer. MFC applications come in several flavours; this one uses a dialog box as the main window. Figure 22.2 shows the application running. Visually the program is just a list box where we can add text information that makes understanding the program’s operation easier. The purpose of the program is to open a server socket on a defined port on a computer with a static IP address and listen for users across the Internet who want to connect to this socket. Whenever there is a new connection it is stored in a list and the program sees to it that all the current listeners to this socket get fed with information. The example program allows remote users to move boxes on another user’s computer and vice versa.