问题
How can I force the socket to be flushed before next data to be send?
Example code:
public function socketSend(data:String):void
{
socket.writeUTFBytes(data);
socket.flush();
}
This works basically fine. But sometimes, it doesn't flush the socket, but combine current information with next information and send together. This is what I don't want because it breaks my application communication.
For example, if I call socketSend('command1')
and then call socketSend('command2')
I am hoping it will send the command1
first then later command2
. But sometimes it sends both together, making the send string become command1command2
. This breaks the application communication.
How can I force it to flush before putting in next set of information? How can I check whether the information is flushed from the socket?
Thank you.
来源:https://stackoverflow.com/questions/20772644/flex-force-socket-to-flush