I have a XMLSocket and I call send twice in the same function. The first send works but the second does not? Does XMLSocket have a restriction to only send one message per frame? Do I have to queue messages and have an onEnterFrame function that checks the queue and sends one message for a frame?
Asked
Active
Viewed 540 times
0
-
In what way doesn't it work? Do you get an error, or doesn't the server receive the data from the second call, or doesn't the event fire for the second call? XMLSocket.send is asynchronous so it doesn't send the data immediately – Les Nov 10 '09 at 15:15
-
The server never receives the data. – zooropa Nov 10 '09 at 20:31
-
Can you provide us with a test case? (The minimum amount of code required to reproduce the problem). – Jotham Nov 11 '09 at 03:35
1 Answers
1
You have to flush the output buffer when you use the Socket class. Example:
public static function write(msg:String):void
{
socket.writeUTFBytes(msg);
socket.flush();
}
However, you're saying that you're using the XMLSocket class? That one provides less lower level posibilities and should already do the flushing for you so I don't think you'd have this problem if your code is correct.
You could try to use the lower level Socket class, and flush the output buffer manually every time you call the write method. See: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/Socket.html

Tom
- 8,536
- 31
- 133
- 232
-
I need the fla to work on a Windows Mobile device so I have to use Flash 7 which does not have the Socket class. – zooropa Nov 12 '09 at 12:26