(lib network) Should inet_aton be called instead of inet_addr ?

Marc Weber marco-oweber at gmx.de
Thu Sep 18 09:24:21 EDT 2008

On Thu, Sep 18, 2008 at 02:32:45AM +0200, Marc Weber wrote:
> Hi @ll
> Reading http://linux.die.net/man/3/inet_addr I noticed that 
> inet_addr is obsolete and inet_aton should be used because inet_addr
> indicates error by returning -1 which is a valid address (
> as well.
> Don't know wether it's worth changing or wether inet_aton is peresent on
> all systems

I'd also suggest  to change
        inet_addr :: String -> IO HostAddress -- throwing user exception
        inet_addr :: String -> IO (Maybe HostAddress) -- not throwing any exception
        inet_addr :: String -> IO (Either String HostAddress) -- not throwing any exception

because the latter can be type checked the first one not..
The problem with the first one is that using a custom exception (which
is easy when extensible extensions become standard) would be a better
choice. But changing the exception type would break libraries.
Using a return type of Maybe would never ever break things again

See also my last post on haskell-cafe


More information about the Libraries mailing list