A socket server is an application that can accept "socket" connections. Socket connections are persistent which means they let you remain connected to a server, rather than making a connection just long enough to download information and then disconnecting. Unlike a scripted page, a socket server is an application that's always running. It can accept numerous simultaneous connections and exchange information between them. Thus, while you're connected to a socket server, you can send or receive information any time. Using socket connections to continually transfer data to and from the server is how most chats and multiplayer games are created in Flash. A key thing to understand about using socket connections with Flash is that you don't have to request information to get it for example, in a chat application a message can be pushed into Flash at any time without Flash having to ask for it.
You cannot, however, just drop a socket server into the CGI-bin of your Web site or place it in a normal Web-accessible directory. Usually written in Java, C, C++, or Visual Basic, socket servers require root-level access to the Web server which usually means you need to be running your own dedicated server to install and use a socket server. You can, however, set up a socket server on your own personal computer so that you can develop with it. For the next exercise, we'll show you how to get a server up and running on your local machine so that you can go on to build a simple chat application that connects to a socket server. To test it, you'll need to use Windows 98, Windows 2000, Windows XP, or Mac OS X. The accompanying CD-ROM contains a simple Java-based socket server, called AquaServer. (It was written by Branden Hall of Figleaf Software.) You need to have Java 2 Runtime Environment (JRE) version 1.3.1 or higher installed on your machine to run our socket server, as well as to test the chat program you build in the next section. (Mac OS X comes with the correct version of JRE installed.)
|