Maurizio Lotauro wrote: > Scrive Arno Garrels <arno.garr...@gmx.de>: > >> Francois PIETTE wrote: >>>>> "if FClientNum >= $7FFFFF then" >>>>> currently it wraps around after 8,388,607 >>>> >>>> That is probably my bug, missed an F. >>> >>> Should probably be MAXINT to avoid any issue with integer size >>> change. >> >> And a cast of FClientNum to an unsigned integer is required, >> otherwise the equal or greater comparison won't work if for some >> reason an integer overflow already happend. If Integer will ever be >> changed in size I guess that Cardinal gets the same size. > > Cardinal and Integer should not change since (IIRC) NativeInt and > NativeUInt was introduced to handle 32/64 bit cpu.
That's correct Integer will remain 32 bit in x64 however might change in the far future and Longint most likely never changes its size even in x128. > >> if Cardinal(FClientNum) >= MaxInt then >> FClientNum := 0; > > FClientNum is declared as LongInt, so maybe MaxLongint should be used. Didn't notice that FClientNum is declared as Longint, so indeed MaxLongint should be used. > > And why don't invert the test? > > if FClientNum) < MaxLongint then > Inc(FClientNum) > else > FClientNum := 1; I don't know why there is/was the ">=" comparison, I guess that Angus wanted to build-in some kind of strange fault-tolerance? However provided that FClientNum is only ever incremented in TCustomWSocketServer.TriggerSessionAvailable (which it realy should) you are perfectly right here as well. -- Arno Garrels > > Bye, Maurizio. > > > ---------------------------------------------------- > This mail has been sent using Alpikom webmail system > http://www.alpikom.it -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be