Chapter 20
Multiplexed XML Sockets
Goals:

In the last chapter we built a system built on XML Sockets. We created a server-side application that accepted a connection request and opened a new socket. This new socket connected to a Flash XMLSocket on the client machine.

This gives us a two-way connection between client and server. Either can initiate a message - and each side can receive them. The ActionScript side was more authentically event-driven, while the PHP actually polled the socket.

In this, our final chapter, we will extend the software from the last chapter to make a multiplexed server. This is a server that manages multiple simultaneous clients.

A server like this is necessary, of course, just to scale the previous project to commercial strength. A system that requires a dedicated server process for each client is generally not ready for public deployment in the Internet. (There are a few exceptions with extremely limited traffic.) So multiplexing our server is important just to provide good single-user service.

But the excitement comes when these clients are not treated in isolation. When the server passes messages from one client to another, we have entered a new type of web experience. Visitors are in direct contact with one another.

Both one-to-one relationships and many-to-many architectures have use in entertainment and functional websites. The power of a growing community and the realtime creativity of individual visitors are a great source of self-renewing content .

Many games and other projects can be started with this technology. We will choose as our working example an application of great simplicity and enduring interest: chat.

Caution

The authors and publishers provide these techniques for professional educational purposes 
and will not be responsible for damages arising from their misuse, accidental or intentional .

These techniques, used carelessly, can cause an interruption of your web service. Depending on your situation, they also might impair the function of other organizations with whom you share resources. You may be unaware of these shared resources, of these organizations, and of the potential consequences of a service interruption.

It is irresponsible to experiment with these functions unless you are competent in the technology and can be certain that you are protecting yourself and respecting the rights of others.