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 t
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 ByteA
On Wed, Feb 24, 2010 at 12:36 AM, Valentin Schmidt wrote:
>> And if you use an "if" instead of "while",
>> then you lose even more incoming data.
>
> how come?
Ok, here your suggestion again:
private function handleTcpData(event:Event):void {
if(_socket.bytesAvailable) { // USE IF, NOT WHILE!
> And if you use an "if" instead of "while",
> then you lose even more incoming data.
how come?
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Hello Valentin,
On Wed, Feb 24, 2010 at 12:06 AM, Valentin Schmidt wrote:
> so then why did you start with posting code here (pasted below) that
> didn't contain any exception catching? that's the crucial point: you
> have to catch the exception, otherwise you would either get corrupted
> UTF str
some comments added to make it easier for you to spot the differences :-)
private function handleTcpData(event:Event):void {
if(_socket.bytesAvailable) { // USE IF, NOT WHILE!
try{ // CATCH THE EXCEPTION
var str:String = _socket.readUTF();
updateGUI(str);
}catch(e:Error){}
Alexander Farber wrote:
> Yes, that's with what I had started and what doesn't work :-)
so then why did you start with posting code here (pasted below) that
didn't contain any exception catching? that's the crucial point: you
have to catch the exception, otherwise you would either get corrupted
UT
Yes, that's with what I had started and what doesn't work :-)
On Tue, Feb 23, 2010 at 11:17 PM, Valentin Schmidt wrote:
> private function handleTcpData(event:Event):void {
> if(_socket.bytesAvailable) {
> try{
> var str:String = _socket.readUTF();
> updateGUI(str);
> }catch(e:Er
Alexander Farber wrote:
> I've come up with this, but still have a flaw there:
>
> private function handleTcpData(event:Event):void {
> var len:uint;
what about this simple alternative:
private function handleTcpData(event:Event):void {
if(_socket.bytesAvailable) {
try{
var str
I've added some traces there and see that this doesn't work:
if (_ba.bytesAvailable >= len) {
var str:String = _ba.readUTFBytes(len);
updateGUI(str);
// copy the remaining bytes
I've come up with this, but still have a flaw there:
private function handleTcpData(event:Event):void {
var len:uint;
if (0 == _socket.bytesAvailable)
return;
try {
_socket.readBytes(_ba, _ba.bytesAvailable,
_socket
> private function handleTcpData(event:Event):void {
>while (_socket.bytesAvailable) {
> var str:String = _socket.readUTF();
> updateGUI(str);
>}
> }
maybe you shouldn't ignore thrown errors: AFAIK if the UTF8-data is not
complete (ie.. the last UTF-8 byte sequence is truncate
Hello,
On Tue, Feb 23, 2010 at 2:25 PM, Henrik Andersson wrote:
> Doing anything but copying the data from the event to your own bytearray
> buffer object is a disaster waiting to happen.
>
> TCP is a stream based protocol, you can get chunks of any length each time
> the event is reviced. Assume
Doing anything but copying the data from the event to your own bytearray
buffer object is a disaster waiting to happen.
TCP is a stream based protocol, you can get chunks of any length each
time the event is reviced. Assume that the chunks are random length and
piece them together in a buffer
Hello,
I have multiplayer game, which reads XML data from the server:
_socket = new Socket();
_socket.addEventListener(ProgressEvent.SOCKET_DATA, handleTcpData);
.
private function handleTcpData(event:Event):void {
while (_socket.bytesAvailable) {
var str:String = _socket.readUTF
15 matches
Mail list logo