-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Description
In Node 5.7.0 and all currently-supported previous versions, it is possible to try to trigger an exception (EBADF
) with code such as this:
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
socket.setTTL(1);
As @saghul explains in #5023, this is because dgram
instantiates the socket lazily with uv_udp_init()
. If uv_udp_init_ex()
were used instead, then the socket could be created and ready for the various .set*
functions upon creation.
Such a change would probably be semver-major
because createSocket()
might throw whereas currently that is not the case.
There are probably loads of other dangers and considerations. (I'm opening this issue so that the discussion can be had independently of the PR linked above, which is a relatively minor and safe change to a test file. This, on the other hand, would be a much bigger deal...)