[haXe] Re: bug in neko.net.ServerLoop?
Michelangelo Capraro
michelangelo at tinlion.com
Fri Nov 3 21:06:34 CET 2006
Nicolas Cannasse <ncannasse at ...> writes:
>
> nbytes is the number of bytes that's just been readed from the buffer.
> It's possibly lower than cl.buffer.length if not the whole data can be
> read at one time. You should then returns 0 in processClientData and
> wait the buffer to match your message size.
>
> Nicolas
>
thanks for the info Nicolas,
ok, i don't understand enough about it all but i usually see this output with a
couple of trace statements i have:
ServerLoop.hx:167: cl.bufbytes:6138
SqueakServer.hx:64: returnLen:6138 buflen:6138 bufpos:0 MAX_BUFSIZE:65536
that trace from server loop happens after line 166: cl.bufbytes += nbytes;
before the crash i get this:
ServerLoop.hx:167: cl.bufbytes:1441
SqueakServer.hx:64: returnLen:6138 buflen:1441 bufpos:0 MAX_BUFSIZE:65536
notice that returnLen is bigger. returnLen is the length of the data i am
grabbing. the server then crashes with:
ServerLoop.hx:146: $sblit
Called from neko/net/ServerLoop.hx line 221
Called from neko/net/ServerLoop.hx line 180
Called from neko/Lib.hx line 98
below is the code i am using where returnLen is calculated
public static function processClientData( d : ClientObject, buf : String, bufpos
: Int, buflen : Int ):Dynamic
{
var data:String = "";
var commandEnd:Int = buf.indexOf(Std.chr(0));
if (commandEnd != -1) {
data = buf.substr(0, commandEnd);
}
var returnLen:Int = data.length;
if (returnLen > 0) returnLen++;
trace("returnLen:" + returnLen + " buflen:" + buflen + " bufpos:" + bufpos + "
MAX_BUFSIZE:" + neko.net.ServerLoop.MAX_BUFSIZE);
if (data != "") trace("processClientData: \n\n" + data + "\n\n");
return returnLen;
}
More information about the Haxe
mailing list