Skip to content

The getNameInfo API is a little strange #416

@peti

Description

@peti

getNameInfo has the ability to report a name resolution error by means of returning Nothing. When the NI_NAMEREQD flag is not set, resolution will never fail because the function simply returns the IP address we were trying to look up. When NI_NAMEREQD is set, however, the function is supposed to fail when that address can't be resolved. Curiously enough, that failure is communicated through an IOException instead of simply returning Nothing! This is really surprising to me and I find myself writing code like

getNameInfo [NI_NAMEREQD] True False localAddr `catchIO` \_ -> return (Nothing,Nothing)

most of the time.

Is there any particular reason why an IOException is used to communicate a perfectly legitimate result of that function call?

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