<div dir="ltr">How precisely are you trying to run the client? Are you typing it in to the same terminal? If so, then the client is never actually started, because when you type ./cli the input is going to ./serv and not the shell. Try running the client in a separate terminal.<div>
<br></div><div>It works for me here on Mac OS X 10.9.2 with GHC 7.8.2.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 20, 2014 at 10:42 PM, yang.zhao <span dir="ltr"><<a href="mailto:hckjsnzf@gmail.com" target="_blank">hckjsnzf@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi guys,<br>I'm newbie, just begin to learn Haskell.<br>now i write a very simple server and client .<br>
<br>Server:<br>import Control.Concurrent  <br>import System.IO           <br>import Network             <br>
                           <br>port :: Int                <br>port = 1234                <br>                           <br>main :: IO ()              <br>main = withSocketsDo $ do  <br>    s <- listenOn $ PortNumber $ fromIntegral port<br>

    (h, _, _) <- accept s  <br>                           <br>    sline <- hGetLine h    <br>    hPutStrLn h sline      <br>    putStrLn $ "send "++sline<br>    threadDelay 1000000    <br>                           <br>

    hClose h               <br>    sClose s <br><br>Client :<br>import System.IO<br>import Network<br> <br>port :: Int<br>port = 1234<br> <br>main :: IO ()<br>main = withSocketsDo $ do<br>    h <- connectTo "localhost" $ PortNumber $ fromIntegral port<br>

    hPutStrLn h "hello"<br>    bs <- hGetContents h<br>    putStrLn bs<br>    hClose h<br> <br clear="all"><br>And, it doesn't work now . I run ./serv , then run ./cli , they will block all the time. <br>

but,  when i run ./serv, and telnet localhost 1234 in another terminal, it works fine.<br>so i don't know what's the wrong with my code.<br>anybody can tell me about my problem?<br><br>os is Debian 7,  haskell-platform  2012.2.0.0<br>

<br>thanks a lot!!!<span class="HOEnZb"><font color="#888888"><br>-- <br>K.I.S.S.
</font></span></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>