#2005: localhost on mac causes getnameinfo error in safari.
------------------------------------+---------------------------------------
Reporter: alex | Owner:
Type: bug | Status: new
Priority: normal | Milestone: Not GHC
Component: libraries/network | Version: 6.8.2
Severity: normal | Resolution:
Keywords: network localhost ipv6 | Difficulty: Unknown
Testcase: | Architecture: x86
Os: MacOS X |
------------------------------------+---------------------------------------
Comment (by claude):
Hello,
I have the same problem, but I've found a workaround for it. It seems GHC
is compiled by default with support for IPV6 sockets, and everything
dealing with sockets at high level is unfortunately bound to IPV6 engine;
listenOn is a high level function. If you want to bypass the higher
network layer, you can copy-paste code in Network.Socket module and make
your own 'listenOn' (See
http://haskell.org/ghc/docs/latest/html/libraries/network/src/Network.html#listenOn)
The code below tricks the higher layer by forcing the use of IPV4:
module Main where
import Prelude hiding (catch)
import Network (listenOn, accept, sClose, Socket, withSocketsDo,
PortID(..))
import System.IO
import Control.Exception (finally, catch,bracketOnError)
import Network.BSD
import Network.Socket hiding ( accept, socketPort, recvFrom, sendTo,
PortNumber )
main = do
sock <- mylistenOn (PortNumber 8000)
conn <- accept sock
talk conn
sClose sock
where talk (h, n, p) = do
hPutStrLn h "hi!"
hClose h
-- Copied from the Network low level modules
mylistenOn (PortNumber port) = do
proto <- getProtocolNumber "tcp"
bracketOnError
(socket AF_INET Stream proto)
(sClose)
(\sock -> do
setSocketOption sock ReuseAddr 1
bindSocket sock (SockAddrInet port iNADDR_ANY)
listen sock maxListenQueue
return sock
)
Regards.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2005#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs