Thanks that's actually pretty good.
I've never used buffer_seek to move around a buffer, I'm actually asking about that on the forum..
I know we've gone through a lot of bits and bytes stuff but what came to me now is knowing what set of bits/bytes belong to which variable and read as what data type.
Here's what I posted there
Code:
///SEND
buffer_seek(buff, buffer_seek_start, 0);
buffer_write(buff, buffer_u16, 5);
buffer_write(buff, buffer_u8, 51);
buffer_write(buff, buffer_string, "Hello Server!");
network_send_raw(client, buff, buffer_get_size(buff));
Code:
///RECEIVE var val1 = buffer_read(buff,buffer_u16);
var val2 = buffer_read(buff,buffer_u8);
var val3 = buffer_read(buff,buffer_string);
So my question is, how do the reading buffers know what part of the written buffers to read, which should be read, so how does val1 know not to read the value "5" and the value"51, and that only "5" belongs to val1 ?
My assumption is the way bits work, 8 bits in a byte, since 1 byte is used to represent the english language on what I'm assuming GML uses the UTF-8 Table, then only 1 byte has a value, where the other byte since it's a u16 should be empty ? or am I missing something.
buffer_u16 can represent values from 0-65,535 but at the moment it only represents the value 5, so there should be a whole lot of 0s there.. are those 0s being sent with ?
so buffer_write sends this
00000000 00000101
and buffer_read (in order since TCP) will get those bits as they are there ?
I brought this up because on the server I will be able to get the total amount of incoming data, I then use the BIS method which stores a length or received bytes from a set position into a byte array, and then from there I would read bytes from say 9-16 and read it as a 8 bit integer, 17-24 as an 8 bit, but now what about strings.. All I got was the length of all the bytes in total, but I never got the length for each individual message that needs to be read, for stacked integers it's fine but what about a message.
I need to see strings the way I see integers, if I'm sending an 8 bit integer, and I'm expecting an 8 bit integer, then I need to send a predefined sized string too so that I can expect that same size in return. But this all depends on the question.
So I found out that in GML the buffer_string data type has a null terminating character 0x0.
I see that's the ASCII reference to null.
This is where it brings up high bits and so on.. Time for lunch.