Currently you have to call recv in a loop on an UDP socket.
So you have to specify a buffer of a fixed size, which might be too small or too large.
One solution would be to just return an allocated buffer if undefined is passed to recv.
However IMHO an (alternative) event/callback based API would be more suitable, since it is more in line how libuv works. Currently libuv is registering and unregistering a callback on each recv(…).
This also applies for TCP sockets, though I didn't look at that in detail.
Currently you have to call
recv
in a loop on an UDP socket. So you have to specify a buffer of a fixed size, which might be too small or too large.One solution would be to just return an allocated buffer if undefined is passed to recv. However IMHO an (alternative) event/callback based API would be more suitable, since it is more in line how libuv works. Currently libuv is registering and unregistering a callback on each
recv(…)
.This also applies for TCP sockets, though I didn't look at that in detail.