I tried to run some sample code on the Haskell Simple Servers page today:
import Network import Control.Concurrent import System.IO main = withSocketsDo $ do sock <- listenOn $ PortNumber 5002 loop sock loop sock = do (h,_,_) <- accept sock forkIO $ body h loop sock where body h = do hPutStr h msg hFlush h hClose h msg = "HTTP/1.0 200 OK\r\nContent-Length: 5\r\n\r\nPong!\r\n"
I do this on a Mac with El Capitan installed.
When I tried to run this code using httperf as indicated on the web page, I received the following error messages on the console:
ep1: <socket: 29>: hPutChar: resource vanished (Broken pipe) ep1: <socket: 29>: hPutChar: resource vanished (Broken pipe) ep1: <socket: 29>: hPutChar: resource vanished (Broken pipe) ep1: <socket: 29>: hPutChar: protocol error (Protocol wrong type for socket)
Different runs will give different numbers for these messages. Am I doing something wrong, is this a mistake or is this normal expected behavior?
source share