Does i need to free send buffers? When?
Buffer is allocated using malloc. Then i call uv_udp_send.
I see memcpy https://github.com/libuv/libuv/blob/e7ebae26247d2fee0a04547eb7f9aa8f78d4a642/src/unix/udp.c#L695
so i think its ok to free(buf->base) after uv_udp_send.
in tcp example https://github.com/libuv/libuv/blob/e7ebae26247d2fee0a04547eb7f9aa8f78d4a642/docs/code/tcp-echo-server/main.c#L36 buf free on send callback. Its on original buffer or on cloned?
I suppose the documentation could be clearer about that: free it in your uv_udp_send_cb callback.
Its on original buffer or on cloned?
Libuv takes ownership of the buffer (the pointed-to memory) but makes copies of the list of uv_buf_t structs that you pass it.
It looks to me that in the Windows implementation the copying of the uv_but_t is absent, so if the operation is overlapped the caller must be responsible for keeping the uv_buf_t around. Am I correct?
Libuv doesn't have to copy on Windows because WSASendTo() already does.
Thank you, it was not obvious from the MS documentation, but now I see it there:
If this function is completed in an overlapped manner, it is the Winsock service provider's responsibility to capture the WSABUF structures before returning from this call. This enables applications to build stack-based WSABUF arrays pointed to by the lpBuffers parameter.