[Haskell-cafe] Network.Socket error in MacOS 10.5?

Ross Mellgren rmm-haskell at z.odi.ac
Wed Aug 26 14:20:03 EDT 2009


I don't think getNameInfo should work for for AF_UNIX -- the name  
given to SockAddrUnix is a file path, there is no name resolution.  
 From the man page for getnameinfo(3) on OS X:

NAME
    getnameinfo -- socket address structure to hostname and service name

...

DESCRIPTION

...

    The sockaddr structure sa should point to either a sockaddr_in or  
sockaddr_in6 structure
(for IPv4 or IPv6 respectively) that is salen bytes long.



Similarly, from the man page for getnameinfo on my linux box:

...

The sa argument is a pointer to a generic socket address structure (of  
type sockaddr_in or sockaddr_in6) of size salen that holds the input  
IP address and port number.

-Ross
On Aug 26, 2009, at 2:07 PM, Johan Tibell wrote:

> On Wed, Aug 26, 2009 at 6:33 PM, kenny lu<haskellmail at gmail.com>  
> wrote:
>> Hi,
>>
>> I encountered a problem with Network.Socket in MacOS 10.5
>> Here is the code that I am testing,
>>
>> -----------------------------------------
>> -----------------------------------------
>> module Main where
>>
>> import qualified Network.Socket as Socket
>>
>> main :: IO ()
>> main =
>>     do { (hostname, _) <- Socket.getNameInfo [] True False
>> (Socket.SockAddrUnix "localhost")
>>        -- (hostname, _) <- Socket.getNameInfo [] True False
>> (Socket.SockAddrInet 9000  (127 + 0 * 256 + 0 * 256^2 + 1 * 256^3))
>>        ; putStrLn (show hostname)
>>        }
>>
>>
>> Running the above code yields the following error
>> ghc --make -O2 TestSocket.hs
>> [1 of 1] Compiling Main             ( TestSocket.hs, TestSocket.o )
>> Linking TestSocket ...
>> $ ./TestSocket
>> TestSocket: getNameInfo: does not exist (ai_family not supported)
>>
>> If I switch to SockAddrInet instead, the error is gone.
>>
>> I am using GHC 6.10.3 and Network 2.2.1
>
> Is SockAddrUnix supposed to work on Mac OS X? Could you test it by
> e.g. writing a small C program that uses it?
>
> -- Johan
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list