FAQ 5b Updated: 1/10/00 >>>>>> How do I save a game? ============================ If you are running your game as a local application, then you can save your game using the FileStream functions. This will let your create files, write to them, save them, re-open and read them. -------------------------------------------- If your game is an Applet available on the internet then things are a lot harder. Applets are designed with severe security restrictions. Applets cannot get access to a players hard drive. Applets can't even save a file on it's base web server (the computer that sent the applet). What an Applet CAN DO is talk to another application that is operating on it's base web-server (a server side application). The application on the base web-server can then perform the file save and load functions, and talk back to the Applet. The problem for most designers is that they don't have access to the base web-server. While most ISP's will let you place an Applet on your web-site, they are very cautious about allowing their clients to place other kinds of applications on the server machines. it is possible to write and test client/server pairs (your Applet and it's server-side buddy) on your home machine. You just won't be able to install the server-side code without your ISP's permission. HOWEVER, this is becoming less of a problem. SOME DSL connections will provide you with a Static IP (a fixed web address). That means that you can run a web-site from your home computer (using a free web-server like Apache). THEN you can use some of the methods I mention below. When looking for new internet connections, ALWAYS ASK about Static IPs. The more we pressure the industry, the more they will give it to us. -------------------------------------------- With that said, lets talk about the methods an Applet can use to talk to a server side application. There are two methods for talking to the server side: CGI calls and Socket connections. -------------------------------------------- CGI's are applications you can launch using HTTP communications. You can activate a CGI just by typing it's path (web-address) into a browser command line. The CGI response can be capture by whoever transmitted the request. Here's an example CGI from my web-site: http://www.fiends.com/cgibin/Voter.exe?cfg=GoatBoy&act=list Many web-sites build all their pages using CGIs. This allows them to track user identity or put a time limit on sessions. it also gives them greater control over access to files. Applets can call a CGI just like any other internet resource. The only limitation is that the CGI has to be on the Applets base web-server (again severe security restrictions). The Applet can capture the CGI's response and use that information. If you want to learn more about CGI's then see FAQ_4c. -------------------------------------------- Sockets provide continuous communication. Star Dart uses Sockets as do most Chat Rooms. A Socket Server is a continuously running application that operates on the server side (your web-server machine). Unlike CGI's (which launch, finish a task, then quit) Socket Servers need to keep operating as long as the game is in play. Clien Side Sockets (the Applet) are relatively easy to write. You open a connection, then send and recieve messages. Server Side Sockets can be very tricky. You will need to maintain one connection per player, record the game state for each player, then update the game world and tell all the players about any changes. Actually, writing Socket Service is DA BOM! When you get that stuff to work, it's like main-lining caffeine. I love the smell of bandwidth in the morning! Applet security restrictions prevent them from opening Sockets with any machine other than their base web-server. If you want to learn more about Sockets then see FAQ_4d.