{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/2604","labels_url":"https://api.github.com/repos/nodejs/node/issues/2604/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/2604/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/2604/events","html_url":"https://github.com/nodejs/node/issues/2604","id":103787352,"number":2604,"title":"Dgram reuseAddr not working with cluster","user":{"login":"hit9","id":1687443,"avatar_url":"https://avatars.githubusercontent.com/u/1687443?v=3","gravatar_id":"","url":"https://api.github.com/users/hit9","html_url":"https://github.com/hit9","followers_url":"https://api.github.com/users/hit9/followers","following_url":"https://api.github.com/users/hit9/following{/other_user}","gists_url":"https://api.github.com/users/hit9/gists{/gist_id}","starred_url":"https://api.github.com/users/hit9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hit9/subscriptions","organizations_url":"https://api.github.com/users/hit9/orgs","repos_url":"https://api.github.com/users/hit9/repos","events_url":"https://api.github.com/users/hit9/events{/privacy}","received_events_url":"https://api.github.com/users/hit9/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/cluster","name":"cluster","color":"f7c6c7"},{"url":"https://api.github.com/repos/nodejs/node/labels/dgram","name":"dgram","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-08-28T20:10:06Z","updated_at":"2015-08-29T07:48:31Z","closed_at":null,"body":"Hi, it seems that `reuseAddr` is not working well with cluster module, when we bind dgram socket in\r\na worker process. The following case runs well, I could run this program for two or more instances without an EADDRINUSE error, this is the except behavior.\r\n\r\n```js\r\nvar dgram = require('dgram');\r\ndgram.createSocket({type: 'udp4', reuseAddr: true}).bind(9527);\r\n```\r\nBut this EADDRINUSE error occurred when the socket was created and bound in a cluster worker:\r\n\r\n```js\r\nvar dgram = require('dgram');\r\nvar cluster = require('cluster');\r\n\r\nif (cluster.isMaster) {\r\n  cluster.fork();\r\n} else {\r\n  dgram.createSocket({type: 'udp4', reuseAddr: true}).bind(9527);\r\n}\r\n```\r\n\r\nTested with node 0.12.2 and iojs 2.0.2\r\n\r\nIs this a bug or a feature?"},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/135956710","html_url":"https://github.com/nodejs/node/issues/2604#issuecomment-135956710","issue_url":"https://api.github.com/repos/nodejs/node/issues/2604","id":135956710,"user":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"created_at":"2015-08-29T07:48:31Z","updated_at":"2015-08-29T07:48:31Z","body":"1. No, either one or the other, depending on the operating system. Currently `SO_REUSEPORT` is used on non-Linux systems that support it, otherwise `SO_REUSEADDR` is used for those systems that support it.\r\n2. I believe I read somewhere once that Linux uses a hash with [srcIP, srcPort, dstIP, dstPort] as the key, but I could be wrong on that (for UDP anyway). However that could easily be different on other operating systems. As far as I know there is no technical barrier to allowing the usage of `cluster`'s built-in round robin scheduler for UDP sockets."}}