I ran into one more problem, Now that 1.70 is out and socket_send2 is here (Thanks Bailopan), I thought I would continue working on this. Problem was I could not simply stuff the integers or floats into one cell like this:
MyPacket[X] = _:var (for floats)
or
MyPacket[X] = var (for ints)
Because it still only make it one byte large and the Ints are 4 bytes large (32 bit).
I solved it like this:
Code:
new myInt[4];
myInt[0] = (var&255);
myInt[1] = ((var>>8)&255);
myInt[2] = ((var>>16)&255);
myInt[3] = ((var>>24)&255);
And then simply stuffed each value in the array into the packet.
MyPacket[X] = myInt[0];
MyPacket[X+1] = myInt[1];
MyPacket[X+2] = myInt[2];
MyPacket[X+3] = myInt[3];
(a little bit more fancy than above, but the same principle)
Maybe there is a better way to do this than with logic operators but if there isn't I hope this can help.
I thought this might be helpful for someone else trying to send binary data over sockets, for me it works like a charm. Cheers!