module Main where import Network import System.Posix import System.IO import Foreign.C.Types import Foreign.Ptr import Control.Concurrent foreign import ccall unsafe "sendfile" c_sendfile :: Fd -> Fd -> COff -> CSize -> Ptr a -> Ptr COff -> CInt -> IO CInt processConnection h = do fd1 <- openFd name ReadOnly Nothing defaultFileFlags fd2 <- handleToFd h c_sendfile fd1 fd2 (fromIntegral 0) (fromIntegral size) nullPtr nullPtr 0 closeFd fd1 closeFd fd2 where name = "/home/refugee/public_html/woo.c" size = 7020 mainLoop sock = do (h, host, port) <- accept sock forkOS $ processConnection h mainLoop sock main = do sock <- listenOn $ PortNumber 1234 mainLoop sock