{"issue":{"created_at":"2011-12-05T15:42:14Z","state":"open","updated_at":"2011-12-05T15:42:14Z","comments":0,"user":{"gravatar_id":"699e7c3bd5cc60c4e5bbd4d403b51fc3","id":638929,"url":"https://api.github.com/users/mamikk","avatar_url":"https://secure.gravatar.com/avatar/699e7c3bd5cc60c4e5bbd4d403b51fc3?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"mamikk"},"body":"\r\nNode v0.6.5 seems to close dgram sockets when the bind()-call fails, this is fine I guess but when one explicitly closes the socket later with close() it will call close() with -1 as an argument which isn't  a valid file descriptor but it shouldn't do this in any case or at least the documentation should be updated explaining that one shouldn't call close() on sockets where bind() has failed.\r\n\r\nThis test case:\r\n\r\n    var dgram = require('dgram');\r\n\r\n    var sock1 = dgram.createSocket('udp4');\r\n    sock1.bind(12345, '127.0.0.1');\r\n\r\n    var sock2 = dgram.createSocket('udp4');\r\n    sock2.on('error', function(err) {}); /* Eliminate the exception. */\r\n    sock2.bind(12345, '127.0.0.1');\r\n\r\n    sock1.close();\r\n    sock2.close();\r\n\r\nWill result in the following when run under strace:\r\n\r\n    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 6\r\n    ioctl(6, FIONBIO, [1])                  = 0\r\n    fcntl(6, F_SETFD, FD_CLOEXEC)           = 0\r\n    bind(6, {sa_family=AF_INET, sin_port=htons(12345), sin_addr=inet_addr(\"127.0.0.1\")}, 16) = 0\r\n    socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7\r\n    ioctl(7, FIONBIO, [1])                  = 0\r\n    fcntl(7, F_SETFD, FD_CLOEXEC)           = 0\r\n    bind(7, {sa_family=AF_INET, sin_port=htons(12345), sin_addr=inet_addr(\"127.0.0.1\")}, 16) = -1 EADDRINUSE (Address already in use)\r\n    close(7)                                = 0\r\n    close(6)                                = 0\r\n    close(4294967295)                       = -1 EBADF (Bad file descriptor)\r\n","assignee":null,"labels":[],"id":2450609,"number":2273,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"dgram: close on unbound socket will call close(-1)","closed_at":null,"html_url":"https://github.com/joyent/node/issues/2273","url":"https://api.github.com/repos/joyent/node/issues/2273","milestone":null},"action":"opened"}