Is there something like System.Posix in windows?
I want the code below to run on Windows, should I change it?
import IO import Control.Exception hiding (catch) import Control.Concurrent import Network import System.Posix ---cannot be run on windows. main = withSocketsDo (installHandler sigPIPE Ignore Nothing >> main') --so the signal handler cannot be used main' = listenOn (PortNumber 9900) >>= acceptConnections acceptConnections sock = do putStrLn "trying to accept" -- debug msg conn@ (h,host,port) <- accept sock print conn -- debug msg forkIO $ catch (talk conn `finally` hClose h) (\e -> print e) acceptConnections sock talk conn@ (h,_,_) = hGetLine h >>= hPutStrLn h >> hFlush h >> talk conn
for example, if I want the program to exit with ctrl + c, I have to add a handler for SIGINT, so in C ++ write some code as follows:
void callback(int sig) {
But I do not know how to do this in haskell, use FFI?
source share