openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

add `MemoryBuffer@ Socket::ReadBuffer(uint size)` #454

Closed XertroV closed 4 months ago

XertroV commented 5 months ago

Sockets can write buffers but not read them. It's useful to read a buffer so I can reuse code (e.g., read a big thing to a buffer, then have multiple different functions that just read parts of the buffer). The reason for doing this is that I don't always want to read from a socket (e.g., for testing).

Also it would be useful if sockets supported all the types that Dev::Read / Dev::GetOffset support.

There are some asymetries between APIs this would help resolve. E.g., you can read a string of a length from a socket, but you can't do anything with that if there are 0x0 bytes in it b/c you can't write a string of arbitrary size to a MemoryBuffer (no size param so presumably null terminated -- have run into issues like that before, but admittedly haven't tested this case)