|
Hello flexcoders (and Adobe, I hope); I’ve been working on getting a Flex application to
talk to an application on the local machine through an XML socket. Getting this
to work using the Windows Flash player was trivially easy. Getting it to work
using the Mac OS X Flash player has so far proven impossible. I’m using the SimpleServer Java code shown at: http://livedocs.macromedia.com/labs/1/flex20beta2/00002515.html The client code is very simple. It
basically calls socket.connect( “localhost”, 8080) and socket.send(…).
I will paste it into the email below my signature. For these initial tests, the client is
running from the local filesystem and the server is hosted on the same machine. When running using the Mac Flash Player,
the socket is never connected on the client side. However, as soon a the client
calls m_socket.connect(…), the server’s call to socket.accept()
returns. So the server thinks the socket is connected, but the client does not.
When I kill the client by closing the browser window, the server echoes the
text “<server-policy-request/>” to the console which means
that this text was received on the incoming socket. The security policy request is strange,
in that when both client and server are running on the local file system under
Windows, no such request is made. However, I think it’s tangential to the
main problem – it does not seem possible to connect a socket when running
under the OS X Flash Player. I would be very gratefull is someone
could look at my code and tell me that I’ve made a stupid mistake. Thanks. Tobias. Kodak Graphic Communications Canada Company Tobias Patton | Software Developer | Tel: +1.604.451.2700
ext: 5148 | mailto:[EMAIL PROTECTED] | http://www.creo.com <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns="*" layout="vertical" creationComplete="OnCreationComplete()"> <mx:Script> <![CDATA[ private
function OnCreationComplete() : void { m_socket.addEventListener(
DataEvent.DATA, OnSocketData ); m_socket.addEventListener(
Event.CONNECT, OnSocketConnect ); m_socket.addEventListener(
IOErrorEvent.IO_ERROR, OnIOError ); m_socket.addEventListener(
Event.CLOSE, OnClose ); output.text
+= "Connecting socket...\n"; m_socket.connect(
"localhost", 8080 ); } private
function OnSendClick( event : MouseEvent ) : void { m_socket.send(
msg.text + "\n" ); } private
function OnSocketData( event : DataEvent ) : void { output.text
+= event.data + "\n"; } private
function OnSocketConnect( event : Event ) : void { output.text
+= "Socket connected\n"; } private
function OnIOError( event : IOErrorEvent ) : void { output.text
+= "IO Error: " + event.text + "\n"; } private
function OnClose( event : Event ) : void { output.text
+= "Socket closed\n"; } private
function OnSecurityError( event : SecurityErrorEvent ) : void { output.text
+= "Socket security error: " + event.text + "\n"; } private
var m_socket : XMLSocket = new XMLSocket(); ]]> </mx:Script> <mx:HBox> <mx:Label
text="Message:"/> <mx:TextInput
id="msg"/> <mx:Button
label="Send" click="OnSendClick( event )"/> </mx:HBox> <mx:VBox> <mx:Label
text="Output:"/> <mx:TextArea
editable="false" id="output" width="300"
height="200"/> </mx:VBox> </mx:Application> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
YAHOO! GROUPS LINKS
|
- [flexcoders] Flex 2B2: Cross-platform bug in XMLSocket? Tobias Patton
- Re: [flexcoders] Flex 2B2: Cross-platform bug in XMLSo... Weyert de Boer

