{"action":"created","issue":{"url":"https://api.github.com/repos/manastech/crystal/issues/332","labels_url":"https://api.github.com/repos/manastech/crystal/issues/332/labels{/name}","comments_url":"https://api.github.com/repos/manastech/crystal/issues/332/comments","events_url":"https://api.github.com/repos/manastech/crystal/issues/332/events","html_url":"https://github.com/manastech/crystal/pull/332","id":54942978,"number":332,"title":"Added: IPv6, UDP and UNIX sockets","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},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-01-20T21:32:54Z","updated_at":"2015-01-27T12:03:11Z","closed_at":"2015-01-26T22:06:15Z","pull_request":{"url":"https://api.github.com/repos/manastech/crystal/pulls/332","html_url":"https://github.com/manastech/crystal/pull/332","diff_url":"https://github.com/manastech/crystal/pull/332.diff","patch_url":"https://github.com/manastech/crystal/pull/332.patch"},"body":"I refactored and extended the socket stdlib. It somehow models the Ruby library. I skipped the Socket methods (like connect, bind, listen) since the C methods are directly accessible. Classes are organized as follows:\r\n\r\n```yaml\r\n- FileDescriptorIO\r\n  - Socket\r\n    - IPSocket\r\n      - TCPSocket\r\n        - TCPServer\r\n      - UDPSocket\r\n    - UNIXSocket\r\n      - UNIXServer\r\n```\r\n\r\n~~I changed the signature of `TCPServer.new` because I couldn't get `initialize(port, backlog = 128)` to compile along with `initialize(host, port, backlog = 128)`. I didn't try hard, so maybe it's doable.~~\r\n\r\nI also added IPv6 support by replacing gethostbyname for getaddrinfo. This is working fine on my Linux computer, but Darwin uses different sockaddr structs, so maybe I broke support for Macs (I can't check). I tried to have an Addrinfo class/struct but didn't get anything working to create sockets from (I got segfaults, invalid af family errors, etc. I blame pointer casts). I'll push another pull request later.\r\n\r\nNote: using `\"::\"` as a host for TCPServer#new or UDPSocket#bind as the extra benefit of binding to all IPv4 and IPv6 addresses with a single server."},"comment":{"url":"https://api.github.com/repos/manastech/crystal/issues/comments/71636925","html_url":"https://github.com/manastech/crystal/pull/332#issuecomment-71636925","issue_url":"https://api.github.com/repos/manastech/crystal/issues/332","id":71636925,"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},"created_at":"2015-01-27T12:03:11Z","updated_at":"2015-01-27T12:03:11Z","body":"There's still one spec failing in travis related to UDP socket. I had it failing on my machine, did a change (stored the @family and pass it instead of nil in connect and bind) and it started working. I reverted the change and it kept working :open_mouth: . I don't know what's going on, but I'll try to test it on another mac, see if I can reproduce it."}}