Hello, I have written a simple Daytime sever using network-alt[1] (I am sorry if this is off topic, is it ?) The server is:
server port = do
runStreamServer (nullStreamServer {handlerSS = sendDaytime, servSS = port})
sendDaytime = handlerWithHandle $ \hs sa -> do
putStrLn (show sa)
hSetBuffering hs LineBuffering
time <- Time.getClockTime
hPutStrLn hs (show time)
hClose hs
It works, but I have the following problems:
When I run server "10013" from ghci, the prompt returns immediately and if I
do a query to that port I don't get anything, until I go and press enter on
ghci and the daytime is sent to the client. Like if the prompt was blocking
all IO or something like that.
The other problem is that I tried to make a program, so I made
DaytimeServer.hs:
main = do
server "10013"
I compile it and run it. It returns immediately and the server of course, is
not running.
I think what I am missing is that server, after running runStreamServer should
block and be able to reply to all the queries (in the final version I'll also
have runDgramServer as well) and be able to receive a signal, upon which it
should close the socket and finish. How can do that ? Any help will be
appreciated.
Thank you.
--
Pupeno <[EMAIL PROTECTED]> (http://pupeno.com)
[1] http://www.cs.helsinki.fi/u/ekarttun/network-alt/ I am currently using the
select mode.
pgpjGwrvRegcZ.pgp
Description: PGP signature
_______________________________________________ Haskell mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell
