Hi Grzegorz,
1. In:
Code:
Vec2 pos;
Int rcv=sock.receive(addr,&pos,SIZE(pos));
is SIZE(pos) used to define the amount of data to be received, to prevent buffer overflow, or is it used to make sure all the data is received (and thus vulnerable to buffer overflow?).
Also, in the socket tutorial, it is only sending Vec2 or null for the "Hello" packet, so it is easy to distinguish between them with:
Code:
if(rcv==SIZE(pos)) // do something with Vec2 data
But I need to be able to distinguish more than two packets (even if their both Vec2's, as they may contain different data meaning), with something like a Byte, and from that I need to know what type of packet is being sent (e.g. a chat packet, an encrypted login packet, etc). So, 2. Please could you write a quick code snippet to show a good way to identify between packets, and then receive their data of arbitrary types, which is not vulnerable to buffer overflow.
3. Does sock.block(false); make receiving in the Update method a multi-threaded server? I need a multi-threaded server to reduce the chance of packets not being dropped when two arrive at the same time.
Thanks,
Chris