try to use build-in yesod socket bind code on windows (mine seems to make t crash)

This commit is contained in:
Joey Hess 2013-12-06 22:35:11 -04:00
parent 00f3781f47
commit b712e2cf57

View file

@ -39,6 +39,9 @@ import Control.Concurrent
#ifdef __ANDROID__
import Data.Endian
#endif
#ifdef mingw32_HOST_OS
import Data.Conduit.Network (bindPort)
#endif
import Network.Socket (withSocketsDo)
localhost :: HostName
@ -70,7 +73,12 @@ browserProc url = proc "xdg-open" [url]
-}
runWebApp :: Maybe HostName -> Wai.Application -> (SockAddr -> IO ()) -> IO ()
runWebApp h app observer = withSocketsDo $ do
#ifndef mingw32_HOST_OS
sock <- getSocket h
#else
let set = defaultSettings
sock <- bindPort (settingsPort set) (settingsHost set)
#endif
void $ forkIO $ runSettingsSocket webAppSettings sock app
sockaddr <- fixSockAddr <$> getSocketName sock
observer sockaddr