user2556165
user2556165

Reputation:

System.Socket custom InetAddress

I found that System.Socket.Family.Inet module doesn't export constructor of InetAddress. It only exports functions which create a specific addresses. But there is no function which can create a custom one like, for example, "192.168.1.1".

How to create a custom InetAddress?


Note

There are pure functions to work with custom addresses in new version 0.6.2.0:

Upvotes: 0

Views: 75

Answers (1)

ErikR
ErikR

Reputation: 52029

Not ideal since it runs in the IO-monad, but you can use getAddressInfo:

{-# LANGUAGE OverloadedStrings #-}

import System.Socket
import System.Socket.Family.Inet
import System.Socket.Type.Stream
import System.Socket.Protocol.TCP

test = do (addr:_) <- getAddressInfo (Just "192.168.10.1") Nothing aiNumericHost  :: IO [AddressInfo Inet Stream TCP]
          return $ inetAddress (socketAddress addr)

Upvotes: 1

Related Questions