[Haskell-beginners] Convert numeric IP to Network.Socket.HostAddress

Michael Snoyman michael at snoyman.com
Mon Feb 3 05:23:29 UTC 2014


You can use the functionality in Data.IP[1] (from iproutes) to accomplish
this. You'd first use `read` (or a safer version thereof, like
Safe.readMay) to convert a String to an IPv4, and then toHostAddress to
convert that to a HostAddress.

[1] http://hackage.haskell.org/package/iproute-1.2.11/docs/Data-IP.html


On Sun, Feb 2, 2014 at 11:01 PM, harry <voldermort at hotmail.com> wrote:

> I need to convert a numeric IP (such as 1.2.3.4) to a HostAddress for
> consumption by SockAddrInet. The only function I can find to do this is
> inet_addr, which is impure (can do DNS lookups). Is there a pure
> conversion?
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140203/e2a6fb42/attachment.html>


More information about the Beginners mailing list