Table of Contents

XMLSocket.send( ) Method Flash 5

transmit XML-formatted data to a server application
socket.send(xmlObject)

Arguments

xmlObject

An XML object to be converted into a string and sent to the server application or any string containing XML-formatted text.

Description

The send( ) method transmits a message from Flash to a server application via socket. The message to send should be an instance of the XML class but may also be an XML-formatted string. When send( ) is invoked, xmlObject is converted to a string and sent to the remote application, followed by a zero byte (ASCII null). The remote application is not obliged to respond; however, any response sent will trigger socket's onXML( ) event handler.

Example

The following code sends a very simple XML-formatted message to a remote application over the socket mySocket, which is a valid XMLSocket object for which a connection has already been established (note that message is an XML object, not an XMLSocket object; see Example 18-11 under the XMLSocket class entry for a full-fledged XMLSocket sample application):

var message = new XML('<MESSAGE>testing...testing...</MESSAGE>');
mySocket.send(message);

It is also legal to send a string containing XML-formatted text without wrapping it in an XML object. For simple XML messages, this is often sufficient:

mySocket.send('<MESSAGE>testing...testing...</MESSAGE>');

See Also

XMLSocket.onXML( ), XML.send( ); the XMLSocket class


Table of Contents