Skip to content

socket raises exception (un)setting IPv6Only #180

@TravisCardwell

Description

@TravisCardwell

In Network.Socket:socket, 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.

For example, ICMPv6 (protocol number 58) is a protocol that is specifically for IPv6. The issue can be reproduced in GHCi on Linux as follows:

> import Network.Socket
> sock <- socket AF_INET6 Raw 58
*** Exception: setSocketOption: invalid argument (Invalid argument)

The 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions