Being new to this low level network programming there is something I'm not 100% clear on here and I have an inkling its causing me big performance problems.
I can't use the sfml Packet because all the SFML functions in my engine are wrapped in Lua and Lua doesn't have a suitable method of packing data into a Packet, so I've written my own lua equivalent and then use the raw reads and write to send it. It works but its very slow and unreliable even on a LAN.
ANYWAYS, because I don't know how big the received data is I've made a buffer that is bigger than I'd ever expect it to be (4k!!) and then called receive as usual:
Socket.Receive(Buffer, sizeof(Buffer), Received, Sender, Port
Is there a performance hit by using large buffers even if the packet are the same size (about 20 bytes, rather than 4096 that is the size of the buffer)? Is the rest of the buffer filled with undetermined data or does it wait until the buffer is filled before returning a full 4096 bytes worth of data? Is it automatically a null terminated char array thats received or should the sender ensure that a null character is added? is the null character even taken into account?
I'm lost and confused.
Nick