Chapter 19. XML Sockets
In this chapter we learn to create a full socket system connecting our own remote server and our own Flash clients .
The last chapter presented a fairly elementary introduction to sockets. We built an XML proxy using fsockopen() , a simple function that treats the socket system as an input stream. This allows us to use the familiar methods of file i/o to create simple client sockets in PHP.
In this chapter, we return to the same topics and examine them in far more depth. We now use PHP to build server sockets, which are far more demanding and cannot be cast as file operations. We also build client sockets in Flash. We create a single client/server socket connection and a live test program that lets us send data on the round trip.
This chapter is of interest to those who need to build low-latency, persistent connections between user and server. A single- user application would typically involve a streaming data feed, such as a market monitor or some sort of remote real-time instrumentation.
The study of sockets is interesting, but it is difficult. The code samples are problematic . They do not require a privileged account, but they do demand the cooperation of your system administrator.
The functions in this chapter can cause real problems for yourself and for other accounts on your server. Permanent damage (e.g., file system corruption) is unlikely , but experimentation with the functions might result in service interruption or a bandwidth overload. Cleanup might require superuser assistance.