UDP
setBuffer()
Since 0.4.5:
Initializes the buffer used by a UDP instance for buffered reads/writes. The buffer
is used when your application calls beginPacket() and parsePacket(). If setBuffer() isn't called,
the buffer size defaults to 512 bytes, and is allocated when buffered operation is initialized via beginPacket() or parsePacket().
// SYNTAX
Udp.setBuffer(size); // dynamically allocated buffer
Udp.setBuffer(size, buffer); // application provided buffer
// EXAMPLE USAGE - dynamically allocated buffer
UDP Udp;
// uses a dynamically allocated buffer that is 1024 bytes in size
if (!Udp.setBuffer(1024))
{
// on no, couldn't allocate the buffer
}
else
{
// 'tis good!
}
// EXAMPLE USAGE - application-provided buffer
UDP Udp;
uint8_t appBuffer[800];
Udp.setBuffer(800, appBuffer);
Parameters:
unsigned int: the size of the bufferpointer: the buffer. If not provided, orNULLthe system will attempt to allocate a buffer of the size requested.
Returns:
truewhen the buffer was successfully allocated,falseif there was insufficient memory. (For application-provided buffers the function always returnstrue.)