summaryrefslogtreecommitdiff
path: root/testsuite/tests/lib/socket/socket009.hs
blob: c34334e691a809c231c62c0755cc20356130f092 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Sigbjorn and I don't understand what this test is meant to do
-- It simply hangs on stdin!

import IO -- 1.3

import System(getArgs)

main =   getArgs                            >>=        \ [user,host] ->
         let username = (user ++ "@" ++ host) in
         openFile username ReadWriteMode    >>=        \ cd          ->
         hSetBuffering stdin NoBuffering    >>
         hSetBuffering stdout NoBuffering   >>
         hSetBuffering cd NoBuffering       >>
         hPutStr cd speakString             >>
         speak cd

speakString = "Someone wants to speak with you\n"

speak cd =
         (hReady cd                         >>=        \ ready       ->
         if ready then (hGetChar cd >>= putChar)
         else return ()                     >>

         hReady stdin                       >>=        \ ready       ->
         if ready then (getChar >>= hPutChar cd)
         else return ())                    >>

         speak cd