RossMcCaughrain
01-20-2010, 10:38 AM
Hi All,
This is a design type question that im looking for the best implementation method as this is my first Client/Server socket app.
Im writing a Flash client that talks to a PHP server via sockets. Ive implemented the Flash sockets using XMLSocket as the data sent is all in XML.
Ive looked at the Flash documentation and the only difference it gives between the 2 is: "Socket is similar to XMLSocket but does not dictate the format of the received or transmitted data."
So going by that and the fact im sending XML data I chose XMLSocket as it seemed logical enough.
Ive hit a problem though. My server listens for the incoming XML messages and dependent on the XML root node delegates to the plugin assigned to handle it. If the Flash client sends 2 messages within a short period of time though they are getting buffered at the TCP layer and then sent as one message hence the 2nd message is ignored.
Again Flash Docs states (similar for both XMLSocket.send and Socket.write): The send operation is asynchronous; it returns immediately, but the data may be transmitted at a later time
Ok so thats fine, Socket provides a flush method to send the data at once but XMLSocket does not (for some reason).
So ideas on possible solutions:
Use Socket instead of XMLSocket and invoke flush (simple, basic, would work)
Change XML schema to have standard root node and have the server traverse the roots children and process as required (allows for multiple messages in one but may not get around the sending occuring with an incomplete XML message if the data sends mid buffer population)
Other suggestions/better ways?
Cheers all!
Ross
This is a design type question that im looking for the best implementation method as this is my first Client/Server socket app.
Im writing a Flash client that talks to a PHP server via sockets. Ive implemented the Flash sockets using XMLSocket as the data sent is all in XML.
Ive looked at the Flash documentation and the only difference it gives between the 2 is: "Socket is similar to XMLSocket but does not dictate the format of the received or transmitted data."
So going by that and the fact im sending XML data I chose XMLSocket as it seemed logical enough.
Ive hit a problem though. My server listens for the incoming XML messages and dependent on the XML root node delegates to the plugin assigned to handle it. If the Flash client sends 2 messages within a short period of time though they are getting buffered at the TCP layer and then sent as one message hence the 2nd message is ignored.
Again Flash Docs states (similar for both XMLSocket.send and Socket.write): The send operation is asynchronous; it returns immediately, but the data may be transmitted at a later time
Ok so thats fine, Socket provides a flush method to send the data at once but XMLSocket does not (for some reason).
So ideas on possible solutions:
Use Socket instead of XMLSocket and invoke flush (simple, basic, would work)
Change XML schema to have standard root node and have the server traverse the roots children and process as required (allows for multiple messages in one but may not get around the sending occuring with an incomplete XML message if the data sends mid buffer population)
Other suggestions/better ways?
Cheers all!
Ross