Closed Mufanza closed 5 months ago
long offset, long size
was introduced after we migrated our CppServer library to C#, there we use size_t which is 64bit. You should never get values bigger that Int.MaxValue.
Ah, okay - and thanks for the swift reply! Would it make sense to change the parameter type from float to int? Or does it break some kind of backwards compatibility?
In any case, if this is known and there's no danger of overflowing the maximum value then I guess there's no issue - so I'm closing this
Yes mostly for backward compatibility. Maybe in some next major release I'll refactor this.
Hi, First of all, a big thank You to Chronoxor & all the contributors for this amazing library - I've been using it for years and I love it!
Here's one thing that was always perplexing me: The 'Receive' and 'OnReceived' methods of the TcpSession class have the following signatures:
(byte[] buffer, long offset, long size)
However, how can the offset and size parameters be of a long type, if the buffer is just a regular array? The maximum length of an array is an int, not a long! So what happens if the methods receive either the 'offset' or the 'size' argument with a value larger than Int.MaxValue? I'd expect one of the following: Either the method fails with an 'OverflowException' Or the extra value will be truncated, resulting in a loss of data.
Is there a real risk of this happening? I wonder if the argument types could be changed from long to int, or if the method could call itself recursively on a truncated buffer if the size/offset get too big?