c34334e691a809c231c62c0755cc20356130f092
[ghc-hetmet.git] / ghc / tests / lib / socket / socket009.hs
1 -- Sigbjorn and I don't understand what this test is meant to do
2 -- It simply hangs on stdin!
3
4 import IO -- 1.3
5
6 import System(getArgs)
7
8 main =   getArgs                            >>=        \ [user,host] ->
9          let username = (user ++ "@" ++ host) in
10          openFile username ReadWriteMode    >>=        \ cd          ->
11          hSetBuffering stdin NoBuffering    >>
12          hSetBuffering stdout NoBuffering   >>
13          hSetBuffering cd NoBuffering       >>
14          hPutStr cd speakString             >>
15          speak cd
16
17 speakString = "Someone wants to speak with you\n"
18
19 speak cd =
20          (hReady cd                         >>=        \ ready       ->
21          if ready then (hGetChar cd >>= putChar)
22          else return ()                     >>
23
24          hReady stdin                       >>=        \ ready       ->
25          if ready then (getChar >>= hPutChar cd)
26          else return ())                    >>
27
28          speak cd