Fireworks gives developers many options for writing JavaScript to extend the application. JavaScript can access Fireworks functionality through the Fireworks Document Object Model (DOM) or Fireworks API functions. JavaScript command calls and functions can be put in separate JSF text files or nestled into SWF files, exposed inside of Fireworks as Flash panels or modal commands. In both of these cases, though, JavaScript commands are being initiated from within Fireworks.
Fireworks can also receive JavaScript instructions from outside the Fireworks application. These nonlocal instructions are called remote procedure calls, which are processed by the RPC server built into Fireworks. The RPC server runs in the background when the application is open and is always listening for requests to process.
The basic goals when using the RPC server are to establish a TCP socket connection to the Fireworks RPC server and then send JavaScript commands over the channel. A socket is an open connection to a server—in this case, the Fireworks server—and it allows XML-formatted data to be sent and received over the channel. The RPC server accepts only UTF-8 encoded XML data, so the JavaScript commands must be written in XML. You will examine how to form XML versions of Fireworks commands in the section, "RPC XML Fragments".
When the RPC server receives a command, Fireworks runs it and sends a server reply back over the socket, letting the client know whether the operation was successful, along with other information related to the command. This series of events is illustrated in Figure 1, and is the same for all clients. Many languages can be used by the client including, Flash ActionScript 2.0, PHP, C++, or Visual Basic .NET.

Figure 1. Information flowing from client to server during the RPC transaction
Note: All sockets must be local on the same machine as the Fireworks application, so they should connect with the loopback address (127.0.0.1). This will necessarily restrict some functions of the Files object and those related to application launching.