Buffer Questions

Buffers

Summary

I am making a networking framework and I want to incorporate the buffer types, but I have a couple of questions.

Writing instances

When I try to write instances into the buffer, it says it doesn’t accept instances. Would there be a way around this or would I just have to accept this?

Offsets

I am writing data and going to pass it through events, but I was wondering what the offset was for?

I have a couple of ideas, such as where the argument was.

Sizes

I was also wondering how I would determine the size of my buffer, an idea I had was to make it a JSON and get the length of it.

If you have any questions please let me know!

Also if you’re wondering why I don’t use already made networking libraries & frameworks, is because I had a couple of issues with them.

Buffers are not meant for userdatas (for example Roblox instances). They’re purely for handing binary data.

The offset is simply how many bytes are indexed from the start (in buffers, the start is always 0). For example, when you use buffer.readu8 (I’m using 8 bit unsigned integer in this example which is 0-255), it accepts the bufferdata and the offset. buffer.readu8 (and so does any other buffer read function) will return a single number.

You can use this library as reference.