Permalink
Browse files

fixing try/catch error

  • Loading branch information...
MattTuttle committed Feb 24, 2014
1 parent 56a79c8 commit ac71514b7bb3c5372c2a41aea7ab587c248b3c98
Showing with 27 additions and 20 deletions.
  1. +27 −20 hxnet/tcp/Client.hx
View
@@ -62,33 +62,40 @@ class Client implements hxnet.interfaces.IClient
else
{
var select = Socket.select([client], null, null, 0);
var byte:Int = 0;
for (socket in select.read)
{
var size:Int = 0;
try
for (i in 0...bytes.length)
{
for (i in 0...bytes.length)
try
{
size = i;
bytes.set(size, socket.input.readByte());
byte = socket.input.readByte();
}
catch (e:haxe.io.Eof)
{
protocol.loseConnection("disconnected");
client.close();
client = null;
return;
}
catch (e:haxe.io.Error)
{
// end of stream
if (e == Blocked)
{
bytes.set(i, byte);
if (i > 0)
{
protocol.dataReceived(new BytesInput(bytes, 0, i));
}
return;
}
}
}
catch (e:haxe.io.Eof)
{
protocol.loseConnection("disconnected");
client.close();
client = null;
}
catch (e:haxe.io.Error)
{
// End of stream
}
if (size > 0)
{
protocol.dataReceived(new BytesInput(bytes, 0, size));
bytes.set(i, byte);
}
protocol.dataReceived(new BytesInput(bytes, 0, bytes.length));
}
}
}

0 comments on commit ac71514

Please sign in to comment.