Name
XMLSocket.send( ) Method — transmit XML-formatted data to a server application
Availability
Flash 5
Synopsis
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 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(
)
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.