{"action":"created","issue":{"url":"https://api.github.com/repos/haskell/network/issues/180","labels_url":"https://api.github.com/repos/haskell/network/issues/180/labels{/name}","comments_url":"https://api.github.com/repos/haskell/network/issues/180/comments","events_url":"https://api.github.com/repos/haskell/network/issues/180/events","html_url":"https://github.com/haskell/network/issues/180","id":105305633,"number":180,"title":"socket raises exception (un)setting IPv6Only","user":{"login":"TravisCardwell","id":6510764,"avatar_url":"https://avatars.githubusercontent.com/u/6510764?v=3","gravatar_id":"","url":"https://api.github.com/users/TravisCardwell","html_url":"https://github.com/TravisCardwell","followers_url":"https://api.github.com/users/TravisCardwell/followers","following_url":"https://api.github.com/users/TravisCardwell/following{/other_user}","gists_url":"https://api.github.com/users/TravisCardwell/gists{/gist_id}","starred_url":"https://api.github.com/users/TravisCardwell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TravisCardwell/subscriptions","organizations_url":"https://api.github.com/users/TravisCardwell/orgs","repos_url":"https://api.github.com/users/TravisCardwell/repos","events_url":"https://api.github.com/users/TravisCardwell/events{/privacy}","received_events_url":"https://api.github.com/users/TravisCardwell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-09-08T05:43:53Z","updated_at":"2015-09-10T07:49:49Z","closed_at":null,"body":"In [Network.Socket:socket](https://github.com/haskell/network/blob/16095dbd5b477afc6ebb0f67cd9b43cf68eeded7/Network/Socket.hsc#L329), the `IPv6Only` socket option is set to `0` so that both IPv4 and IPv6 can be handled with one socket, when the address family is `AF_INET6`.  This is not always desired, and some parameters cause an exception to be raised.\r\n\r\nFor example, [ICMPv6](https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_version_6) (protocol number 58) is a protocol that is specifically for IPv6.  The issue can be reproduced in GHCi on Linux as follows:\r\n\r\n```\r\n> import Network.Socket\r\n> sock <- socket AF_INET6 Raw 58\r\n*** Exception: setSocketOption: invalid argument (Invalid argument)\r\n```\r\n\r\nThe code already suppresses `setSocketOption` errors on Windows platforms.  A simple fix would be to do so on all platforms, and I am preparing a pull request for this.  Personally, I feel that it would be preferable to not set the option in `socket`, especially since its appropriateness is application-specific and will likely change as IPv4 becomes less prominent."},"comment":{"url":"https://api.github.com/repos/haskell/network/issues/comments/139150706","html_url":"https://github.com/haskell/network/issues/180#issuecomment-139150706","issue_url":"https://api.github.com/repos/haskell/network/issues/180","id":139150706,"user":{"login":"kazu-yamamoto","id":165387,"avatar_url":"https://avatars.githubusercontent.com/u/165387?v=3","gravatar_id":"","url":"https://api.github.com/users/kazu-yamamoto","html_url":"https://github.com/kazu-yamamoto","followers_url":"https://api.github.com/users/kazu-yamamoto/followers","following_url":"https://api.github.com/users/kazu-yamamoto/following{/other_user}","gists_url":"https://api.github.com/users/kazu-yamamoto/gists{/gist_id}","starred_url":"https://api.github.com/users/kazu-yamamoto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kazu-yamamoto/subscriptions","organizations_url":"https://api.github.com/users/kazu-yamamoto/orgs","repos_url":"https://api.github.com/users/kazu-yamamoto/repos","events_url":"https://api.github.com/users/kazu-yamamoto/events{/privacy}","received_events_url":"https://api.github.com/users/kazu-yamamoto/received_events","type":"User","site_admin":false},"created_at":"2015-09-10T07:49:49Z","updated_at":"2015-09-10T07:49:49Z","body":"In the current pull request, it seems to me that `IPv6Only` is not set to `0` on Vista or laster. Is this intentional? If I remember correctly, default value of IPV6_V6ONLY is platform specific. That's why we explicitly set it to `0` here."}}