{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/3780","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3780/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3780/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3780/events","html_url":"https://github.com/crystal-lang/crystal/issues/3780","id":197520220,"number":3780,"title":"Can't create Socket::IPAddress for localhost","user":{"login":"asterite","id":209371,"avatar_url":"https://avatars.githubusercontent.com/u/209371?v=3","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"labels":[{"id":20487867,"url":"https://api.github.com/repos/crystal-lang/crystal/labels/bug","name":"bug","color":"fc2929","default":true},{"id":253019694,"url":"https://api.github.com/repos/crystal-lang/crystal/labels/standard%20library","name":"standard library","color":"fad8c7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-12-26T00:26:37Z","updated_at":"2016-12-26T12:37:25Z","closed_at":null,"body":"```cr\r\nrequire \"socket\"\r\n\r\nSocket::IPAddress.new(\"localhost\", 1234) # => Invalid IP address: localhost (Socket::Error)\r\n```\r\n\r\n@ysbaddaden Any idea how to fix this? Someone mentioned this issue [here](https://groups.google.com/forum/?fromgroups#!topic/crystal-lang/PYURCY11quE)"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/269207686","html_url":"https://github.com/crystal-lang/crystal/issues/3780#issuecomment-269207686","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3780","id":269207686,"user":{"login":"ysbaddaden","id":47380,"avatar_url":"https://avatars.githubusercontent.com/u/47380?v=3","gravatar_id":"","url":"https://api.github.com/users/ysbaddaden","html_url":"https://github.com/ysbaddaden","followers_url":"https://api.github.com/users/ysbaddaden/followers","following_url":"https://api.github.com/users/ysbaddaden/following{/other_user}","gists_url":"https://api.github.com/users/ysbaddaden/gists{/gist_id}","starred_url":"https://api.github.com/users/ysbaddaden/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ysbaddaden/subscriptions","organizations_url":"https://api.github.com/users/ysbaddaden/orgs","repos_url":"https://api.github.com/users/ysbaddaden/repos","events_url":"https://api.github.com/users/ysbaddaden/events{/privacy}","received_events_url":"https://api.github.com/users/ysbaddaden/received_events","type":"User","site_admin":false},"created_at":"2016-12-26T12:37:25Z","updated_at":"2016-12-26T12:37:25Z","body":"`Socket#bind(host, port)` uses `Socket#Addrinfo.resolve` internally, which can be quite confusing to use, I admit. I'd love a better design, but there are a bunch of constraints; mostly: avoid intermediary structs (or worse, HEAP), avoid raising if we can't connect (raising is expensive) until we tried all the possible `Addrinfo`, ...\r\n\r\nDNS is made in such a way that we can't resolve a domain to an unique IP but to many, which will differ depending on the service (http, domain, mail, ...), but still possibly returning many IP for a single service... Even `localhost` may return `127.0.0.1` as well as `::1` or even `127.0.1.1` and maybe even more addresses.\r\n\r\nI added documentation and a non block form of `Addrinfo.resolve` that returns an `Array(Addrinfo)` in #3781, so it's nicer to use and less confusing than the block form. What do you think?"}}
{"actor":{"display_login":"ysbaddaden"}}