Take a look at the Adobe documentation on XMLSocket, it may be possible to just send<br>null terminated strings instead of well formed XML. I recall something like that is possible. <br><br><br><br><br><div class="gmail_quote">
On Thu, May 8, 2008 at 10:02 AM, Evaldas Taroza &lt;<a href="mailto:etaroza@optaros.com">etaroza@optaros.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for the code, it gave me initial idea on where to start. Still, the code is showing XMLSocket, so it assumes that I am receiving XML data. But As I mentioned previously, the incoming data (at least in the beginning) is not well formed XML and should be treated as a simple string...<br>

<br>
So I suppose there is some Flash API for that, isn&#39;t there?<br>
<br>
How does it work technically that OL can communicate to Flash using Javascript?<br>
<br>
Evaldas<br>
<br>
Henry Minsky wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
We do something similar with the remote debug protocol.<br>
<br>
if you look at the file &nbsp;WEB-INF/lps/lfc/debugger/platform/swf/LzRemote.as you will see the usage<br>
of the Flash APIs. They can be accessed as normal Javascript for the most part.<br>
<br>
For example the code to open and send a message looks like<br>
<br>
Debug.sockOpen = function (port) {<br>
 &nbsp;var url = LzBrowser.getLoadURLAsLzURL();<br>
 &nbsp;// Security requires us to talk back to the server we were loaded from<br>
 &nbsp;var host = url.host;<br>
 &nbsp;this.xsock = new XMLSocket();<br>
 &nbsp;this.xsock.onClose = this.brokensocket;<br>
 &nbsp;this.xsock.onXML = this.socketXMLAvailable;<br>
 &nbsp;if (! this.xsock.connect(host, port)) {<br>
 &nbsp; &nbsp;Debug.log(&quot;remote debugger could not connect to listener &quot; + host + &quot;:&quot; + port);<br>
 &nbsp;}<br>
 &nbsp;this.writeInitMessage();<br>
}<br>
<br>
<br>
/**<br>
 &nbsp;* @access private<br>
 &nbsp;*/<br>
Debug.writeInitMessage = function () {<br>
 &nbsp; &nbsp;var filename = LzBrowser.getLoadURLAsLzURL();<br>
 &nbsp; &nbsp;var myXML = new XML();<br>
 &nbsp; &nbsp;var init = myXML.createElement(&quot;init&quot;);<br>
 &nbsp; &nbsp;myXML.appendChild(init);<br>
 &nbsp; &nbsp;init.attributes.filename &nbsp; &nbsp; &nbsp; &nbsp; = filename;<br>
 &nbsp; &nbsp;init.attributes.language &nbsp; &nbsp; &nbsp; &nbsp; = &quot;LZX&quot;;<br>
 &nbsp; &nbsp;init.attributes.protocol_version = &quot;1.0&quot;;<br>
 &nbsp; &nbsp;init.attributes.build &nbsp; &nbsp; &nbsp;= canvas.lpsbuild;<br>
 &nbsp; &nbsp;init.attributes.lpsversion = canvas.lpsversion;<br>
 &nbsp; &nbsp;init.attributes.lpsrelease = canvas.lpsrelease;<br>
 &nbsp; &nbsp;init.attributes.runtime &nbsp; &nbsp;= canvas.runtime;<br>
 &nbsp; &nbsp;init.attributes.appid &nbsp; &nbsp; &nbsp;= &quot;0&quot;;<br>
 &nbsp; &nbsp;this.xsock.send(myXML);<br>
}<br>
<br>
<br>
and the code to hook into the callback for received XML looks like<br>
<br>
Debug.socketXMLAvailable = function (doc) {<br>
 &nbsp; &nbsp;var e = doc.firstChild;<br>
 &nbsp; &nbsp;var rloader = Debug.rdbloader;<br>
 &nbsp; &nbsp;if (e != null) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;// clear warnings history<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Debug.resetWarningHistory();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Debug.inEvalRequest = true;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;var seqnum = e.attributes[&#39;seq&#39;];<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (seqnum == null) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;seqnum = Debug.seqnum++;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;if (e.nodeName == &quot;exec&quot;) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var expr = e.firstChild.nodeValue;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rloader.request( { lz_load : false,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lzt : &quot;eval&quot;,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proxied: true,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lzrdbseq : seqnum,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lz_script : &quot;#file evalString\n#line 0\n&quot; + expr } );<br>
 &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp; &nbsp;} else if (e.nodeName == &quot;eval&quot;) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var expr = e.firstChild.nodeValue;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rloader.request( { &nbsp;lz_load : false,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lzt : &quot;eval&quot;,<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;proxied: true,<br></div></div>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;n bsp; &nbsp; &nbsp;lzrdbseq : seqnum,<div class="Ih2E3d"><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lz_script : &quot;#file evalString\n#line 0\n&quot; + expr } );<br>
 &nbsp; &nbsp; &nbsp; &nbsp;} else if (e.nodeName == &quot;inspect&quot;) {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Debug.inEvalRequest = false;<br></div>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var id = <a href="http://e.attributes.id" target="_blank">e.attributes.id</a> &lt;<a href="http://e.attributes.id" target="_blank">http://e.attributes.id</a>&gt;;<div class="Ih2E3d"><br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Debug.sockWriteAsXML(Debug.ObjectForID(id), seqnum);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;} else {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Debug.inEvalRequest = false;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Debug.sockWrite(&quot;&lt;response seq=&#39;&quot;+seqnum+&quot;&#39;&gt;&lt;error msg=&#39;unknown remote debug command&#39;&gt;&quot;+e.nodeName+&quot;&lt;/error&gt;&lt;/response&gt;&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp;} else {<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Debug.inEvalRequest = false;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Debug.sockWrite(&quot;&lt;response seq=&#39;-1&#39;&gt;&lt;error msg=&#39;null remote debug command&#39;/&gt;&lt;/response&gt;&quot;);<br>
 &nbsp; &nbsp;}<br>
}<br>
<br>
<br>
<br>
<br>
You may want to put some of that code into a &lt;script when=&quot;immediate&quot;&gt; block<br>
<br></div><div><div></div><div class="Wj3C7c">
On Thu, May 8, 2008 at 9:30 AM, Evaldas Taroza &lt;<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a> &lt;mailto:<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a>&gt;&gt; wrote:<br>

<br>
 &nbsp; &nbsp;Hello,<br>
<br>
 &nbsp; &nbsp;Thanks Henry for the pointer. Indeed I need a TCP socket. Normal<br>
 &nbsp; &nbsp;Dataset will not do the job, I think.<br>
<br>
 &nbsp; &nbsp;When you say to use Flash API, how do I do it? I mean, in Flash I<br>
 &nbsp; &nbsp;suppose there is another programing language, like ActionScript, so<br>
 &nbsp; &nbsp;how do I do it from within OL then?<br>
<br>
 &nbsp; &nbsp;And when you say that Flash API is not officially supported by OL<br>
 &nbsp; &nbsp;can it be that my app will eventually break, when you change<br>
 &nbsp; &nbsp;somethings inside OL?<br>
<br>
 &nbsp; &nbsp;A bit about my problems:<br>
 &nbsp; &nbsp;As I told you I am taking my first steps with OL. So I decided to<br>
 &nbsp; &nbsp;write some simple chat program, which would support a very small<br>
 &nbsp; &nbsp;subset of XMPP. So as a start I need to send to the chat server the<br>
 &nbsp; &nbsp;following text:<br>
 &nbsp; &nbsp;&lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39;?&gt;<br>
 &nbsp; &nbsp; &lt;stream:stream<br>
 &nbsp; &nbsp; &nbsp; to=&#39;localhost&#39;<br>
 &nbsp; &nbsp; &nbsp; xmlns=&#39;jabber:client&#39;<br>
 &nbsp; &nbsp; &nbsp; xmlns:stream=&#39;<a href="http://etherx.jabber.org/streams" target="_blank">http://etherx.jabber.org/streams</a>&#39;<br>
 &nbsp; &nbsp; &nbsp; version=&#39;1.0&#39;&gt;<br>
<br>
 &nbsp; &nbsp;And the server responds to something similar as well. As you can see<br>
 &nbsp; &nbsp;it is not a well-formed XML document, so I need to treat it as text<br>
 &nbsp; &nbsp;and parse it. All the subsequent communication happens with<br>
 &nbsp; &nbsp;well-formed XML snippets.<br>
<br>
 &nbsp; &nbsp;Do you think it&#39;s possible?<br>
<br>
 &nbsp; &nbsp;Evaldas<br>
<br>
 &nbsp; &nbsp;Henry Minsky wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;For streaming I/O to a TCP socket, if you restrict your self to<br>
 &nbsp; &nbsp; &nbsp; &nbsp;the Flash runtime, you can use the Flash XMLSocket API , which<br>
 &nbsp; &nbsp; &nbsp; &nbsp;has some restrictions, such as it must use TCP ports above 1024<br>
 &nbsp; &nbsp; &nbsp; &nbsp;I think.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;The API can be found in the Flash reference manual, it is not<br>
 &nbsp; &nbsp; &nbsp; &nbsp;officially a supported API in OpelLaszlo though.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;We used this API for one of the remote debugger protocols at one<br>
 &nbsp; &nbsp; &nbsp; &nbsp;point. There is still some code in the debugger implementation<br>
 &nbsp; &nbsp; &nbsp; &nbsp;for it I think, which could be used as an example.<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;On Thu, May 8, 2008 at 12:35 AM, Evaldas Taroza<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a>&gt;<br></div></div>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a><div class="Ih2E3d"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:etaroza@optaros.com" target="_blank">etaroza@optaros.com</a>&gt;&gt;&gt; wrote:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dear OL users,<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I am pretty new to OL. What I am trying to achieve is to open a<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; socket to a host (crossdomain) and read incoming textual data.<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Incoming data will most likely be an XML document, but I<br>
 &nbsp; &nbsp; &nbsp; &nbsp;don&#39;t want<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; to read the whole document, I rather need to deal with it as it<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; comes, in a streaming manner. How can I achieve this?<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Thank you very much for help!<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Evaldas<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- &nbsp; &nbsp;+41 79 616 53 76<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.linkedin.com/in/taroza" target="_blank">www.linkedin.com/in/taroza</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="http://www.linkedin.com/in/taroza" target="_blank">http://www.linkedin.com/in/taroza</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="http://www.linkedin.com/in/taroza" target="_blank">http://www.linkedin.com/in/taroza</a>&gt;<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Optaros - <a href="http://www.optaros.com" target="_blank">www.optaros.com</a> &lt;<a href="http://www.optaros.com" target="_blank">http://www.optaros.com</a>&gt;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="http://www.optaros.com" target="_blank">http://www.optaros.com</a>&gt;<br>
<br>
<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;--  &nbsp; &nbsp; &nbsp; &nbsp;Henry Minsky<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Software Architect<br>
 &nbsp; &nbsp; &nbsp; &nbsp;<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a>&gt;<br></div>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a><div class="Ih2E3d"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;&lt;mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a>&gt;&gt;<br>
<br>
<br>
<br>
<br>
 &nbsp; &nbsp;--  &nbsp; &nbsp;+41 79 616 53 76<br>
 &nbsp; &nbsp;<a href="http://www.linkedin.com/in/taroza" target="_blank">www.linkedin.com/in/taroza</a> &lt;<a href="http://www.linkedin.com/in/taroza" target="_blank">http://www.linkedin.com/in/taroza</a>&gt;<br>
<br>
 &nbsp; &nbsp;Optaros - <a href="http://www.optaros.com" target="_blank">www.optaros.com</a> &lt;<a href="http://www.optaros.com" target="_blank">http://www.optaros.com</a>&gt;<br>
<br>
<br>
<br>
<br>
-- <br>
Henry Minsky<br>
Software Architect<br>
<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a> &lt;mailto:<a href="mailto:hminsky@laszlosystems.com" target="_blank">hminsky@laszlosystems.com</a>&gt;<br>
<br>
</div></blockquote><div><div></div><div class="Wj3C7c">
<br>
<br>
<br>
-- <br>
+41 79 616 53 76<br>
<a href="http://www.linkedin.com/in/taroza" target="_blank">www.linkedin.com/in/taroza</a><br>
<br>
Optaros - <a href="http://www.optaros.com" target="_blank">www.optaros.com</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Henry Minsky<br>Software Architect<br><a href="mailto:hminsky@laszlosystems.com">hminsky@laszlosystems.com</a><br><br>