So I switched from XMLSocket to just plain Socket.
I have this now:
var sock:Socket = new Socket();
But nothing gets transmitted unless I close the Flex app.
I don't get this. What seems to be a problem?
I read an API docs twice and it says that writeUTFBytes (or any other write methods) are just putting stuff in a buffer
the flush() is the one that signals that the buffer content needs to be sent.
I'm doing just that and still I get nothing on the other side unless I close the Flex app.
You can write to socket only after Event.CONNECT event dispatched. As I understand for XMLSocket you haven't call connect() method at all.
See example from docs.
The line: var sock:XMLSocket = new XMLSocket("localhost", 7778);
already establishes the connection. Instead of calling the connect() method I just use the constructor of XMLSocket to this job.
It works and I can send stuff to the server. I can also see it on the server. What causes the problem is the additional
ZERO Byte attached to the XML string sent. I don't know whose idea was to create such object (the XMLSocket object)
that gets this additional zero byte at the end. I think is stupid and I'd fired the programmer that design this..........
I got around the problem using the Socket object instead.
By the way - why do you create a new connection per message every time?
I'd fire a programmer who does that in a commercial product as well
Simply because I can.
It doesn't matter at the moment.
This suppose to be only a test/sample program for someone smart here to tell me how to married
flash client with java server. (how to get the XML string to the other side)
I got it to work, however, the problem remains for those trying to do the same.
Did you write it?