Alexander Farber wrote:
> After some thought... the 2nd case (not enough data arrived)
> is not a problem for your code, because the handleTcpData()
> will get called again - once the rest of the data arrived.
>
> But for the 1st case (several UTF strings arrived at once)...
> Maybe I should try the following (and don't need a ByteArray):
>
> private function handleTcpData(event:Event):void {
> // KEEP EXTRACTING UTF-STRINGS
> while(_socket.bytesAvailable) {
> try{
> var str:String = _socket.readUTF();
> updateGUI(str);
> }catch(e:Error){
> // INCOMPLETE STRING, WILL BE READ LATER
> return;
> }
> }
> }
yes, I think that might be a good idea: the problem I saw peviously was
that if bytesAvailable>0, but for some reason the try-statement fails
(and therefor bytesAvailable isn't set to 0), you would be caught in an
infinite loop, because I don't think the socket data will be updated
from outside while you are inside such an endless repeat-loop.
but by adding this return statement that leaves the loop this can't
happen anymore. good luck :-)
cheers,
valentin
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders