Name
XMLSocket.send( ) Method — transmit XML-formatted data to a server application
Availability
Flash 5
Synopsis
socket.send(XMLobject)
Arguments
- XMLobject
An
XMLobject 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 object of the
XML class but may also be a string. When
send( ) is invoked,
XMLobject is converted to a string and
sent to the remote application, followed by a zero byte (the first
ASCII character, 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 the example
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;
the XMLSocket Class, XML.send(
)
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access