{"action":"created","issue":{"url":"https://api.github.com/repos/diegonehab/luasocket/issues/99","labels_url":"https://api.github.com/repos/diegonehab/luasocket/issues/99/labels{/name}","comments_url":"https://api.github.com/repos/diegonehab/luasocket/issues/99/comments","events_url":"https://api.github.com/repos/diegonehab/luasocket/issues/99/events","html_url":"https://github.com/diegonehab/luasocket/issues/99","id":36676411,"number":99,"title":"non-blocking connects with multiple DNS entries return EALREADY","user":{"login":"daurnimator","id":127971,"avatar_url":"https://avatars.githubusercontent.com/u/127971?v=3","gravatar_id":"","url":"https://api.github.com/users/daurnimator","html_url":"https://github.com/daurnimator","followers_url":"https://api.github.com/users/daurnimator/followers","following_url":"https://api.github.com/users/daurnimator/following{/other_user}","gists_url":"https://api.github.com/users/daurnimator/gists{/gist_id}","starred_url":"https://api.github.com/users/daurnimator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daurnimator/subscriptions","organizations_url":"https://api.github.com/users/daurnimator/orgs","repos_url":"https://api.github.com/users/daurnimator/repos","events_url":"https://api.github.com/users/daurnimator/events{/privacy}","received_events_url":"https://api.github.com/users/daurnimator/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2014-06-27T15:29:08Z","updated_at":"2015-03-03T22:04:04Z","closed_at":null,"body":"Non-blocking connects when theres multiple DNS entries keep iterating through entries after getting `EINPROGRESS` and end up returning `EALREADY` instead.\r\n\r\n```lua\r\ns=require\"socket\"\r\nprint(s._VERSION)\r\nm=s.tcp()\r\nm:settimeout(0)\r\nprint(m:connect(\"google.com\",80))\r\n```\r\n```\r\nLuaSocket 3.0-rc1\r\nnil     Operation already in progress\r\n```\r\nExpected `nil, timeout` instead."},"comment":{"url":"https://api.github.com/repos/diegonehab/luasocket/issues/comments/77046368","html_url":"https://github.com/diegonehab/luasocket/issues/99#issuecomment-77046368","issue_url":"https://api.github.com/repos/diegonehab/luasocket/issues/99","id":77046368,"user":{"login":"daurnimator","id":127971,"avatar_url":"https://avatars.githubusercontent.com/u/127971?v=3","gravatar_id":"","url":"https://api.github.com/users/daurnimator","html_url":"https://github.com/daurnimator","followers_url":"https://api.github.com/users/daurnimator/followers","following_url":"https://api.github.com/users/daurnimator/following{/other_user}","gists_url":"https://api.github.com/users/daurnimator/gists{/gist_id}","starred_url":"https://api.github.com/users/daurnimator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daurnimator/subscriptions","organizations_url":"https://api.github.com/users/daurnimator/orgs","repos_url":"https://api.github.com/users/daurnimator/repos","events_url":"https://api.github.com/users/daurnimator/events{/privacy}","received_events_url":"https://api.github.com/users/daurnimator/received_events","type":"User","site_admin":false},"created_at":"2015-03-03T22:04:04Z","updated_at":"2015-03-03T22:04:04Z","body":"> It would be great if somebody could figure out the portable way for doing non-blocking connects\r\n\r\nI think the pattern (for a single socket) should be call `connect` => poll until writable => call `connect` again.\r\nIf that fails, and you have a 2nd socket you want to try (e.g. IPv4 after IPv6) you'll need to call `connect` again, poll until writable (again) and then call `connect` (again)\r\n\r\nThis flow will be quite uncomfortable with luasocket; as the polling primitive is left to the user (to roll their own multi-tasking).\r\n"}}