• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 20. Multiplexed XML Sockets

Chapter 20. Multiplexed XML Sockets

In the last chapter we built a system 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 or receive a message. The ActionScript side was more authentically event- driven, while the PHP actually polled the socket.

In this, our final chapter, we extend the software 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 port 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.

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 web sites. The power of a growing community and the real-time creativity of individual visitors are a great source of self-renewing content .

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

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.


As noted previously, version 4.0.4 of PHP (current at the time of this writing) cannot do proper nonblocking reads. With multiplexed sockets, it made our software very clumsy. This bug was being corrected at press time.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint