Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  Haskell network sample (Bob Ippolito)
   2. Re:  Haskell network sample (yang.zhao)
   3. Re:  Haskell network sample (Bob Ippolito)
   4. Re:  Haskell network sample (yang.zhao)


----------------------------------------------------------------------

Message: 1
Date: Tue, 20 May 2014 22:47:51 -0700
From: Bob Ippolito <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell network sample
Message-ID:
        <cacwmpm_1zhqgf8sre56dydt5grtnm_maeqsbflch+yxuf-d...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

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.

It works for me here on Mac OS X 10.9.2 with GHC 7.8.2.


On Tue, May 20, 2014 at 10:42 PM, yang.zhao <[email protected]> wrote:

> hi guys,
> I'm newbie, just begin to learn Haskell.
> now i write a very simple server and client .
>
> Server:
> import Control.Concurrent
> import System.IO
> import Network
>
> port :: Int
> port = 1234
>
> main :: IO ()
> main = withSocketsDo $ do
>     s <- listenOn $ PortNumber $ fromIntegral port
>     (h, _, _) <- accept s
>
>     sline <- hGetLine h
>     hPutStrLn h sline
>     putStrLn $ "send "++sline
>     threadDelay 1000000
>
>     hClose h
>     sClose s
>
> Client :
> import System.IO
> import Network
>
> port :: Int
> port = 1234
>
> main :: IO ()
> main = withSocketsDo $ do
>     h <- connectTo "localhost" $ PortNumber $ fromIntegral port
>     hPutStrLn h "hello"
>     bs <- hGetContents h
>     putStrLn bs
>     hClose h
>
>
> And, it doesn't work now . I run ./serv , then run ./cli , they will block
> all the time.
> but,  when i run ./serv, and telnet localhost 1234 in another terminal, it
> works fine.
> so i don't know what's the wrong with my code.
> anybody can tell me about my problem?
>
> os is Debian 7,  haskell-platform  2012.2.0.0
>
> thanks a lot!!!
> --
> K.I.S.S.
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140520/7a3bd7e7/attachment-0001.html>

------------------------------

Message: 2
Date: Wed, 21 May 2014 13:51:41 +0800
From: "yang.zhao" <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell network sample
Message-ID:
        <cakxgz3zbjrhua8fo19ro0shcts3-0p288znt9fmwelud5ju...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

thanks for your replay.
i run the two program in two different teriminal for sure.

it works for you?
but why can't run well on my computer.

make me creazy....


2014-05-21 13:47 GMT+08:00 Bob Ippolito <[email protected]>:

> 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.
>
> It works for me here on Mac OS X 10.9.2 with GHC 7.8.2.
>
>
> On Tue, May 20, 2014 at 10:42 PM, yang.zhao <[email protected]> wrote:
>
>> hi guys,
>> I'm newbie, just begin to learn Haskell.
>> now i write a very simple server and client .
>>
>> Server:
>> import Control.Concurrent
>> import System.IO
>> import Network
>>
>> port :: Int
>> port = 1234
>>
>> main :: IO ()
>> main = withSocketsDo $ do
>>     s <- listenOn $ PortNumber $ fromIntegral port
>>     (h, _, _) <- accept s
>>
>>     sline <- hGetLine h
>>     hPutStrLn h sline
>>     putStrLn $ "send "++sline
>>     threadDelay 1000000
>>
>>     hClose h
>>     sClose s
>>
>> Client :
>> import System.IO
>> import Network
>>
>> port :: Int
>> port = 1234
>>
>> main :: IO ()
>> main = withSocketsDo $ do
>>     h <- connectTo "localhost" $ PortNumber $ fromIntegral port
>>     hPutStrLn h "hello"
>>     bs <- hGetContents h
>>     putStrLn bs
>>     hClose h
>>
>>
>> And, it doesn't work now . I run ./serv , then run ./cli , they will
>> block all the time.
>> but,  when i run ./serv, and telnet localhost 1234 in another terminal,
>> it works fine.
>> so i don't know what's the wrong with my code.
>> anybody can tell me about my problem?
>>
>> os is Debian 7,  haskell-platform  2012.2.0.0
>>
>> thanks a lot!!!
>> --
>> K.I.S.S.
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
K.I.S.S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140521/74f4d77d/attachment-0001.html>

------------------------------

Message: 3
Date: Tue, 20 May 2014 22:57:12 -0700
From: Bob Ippolito <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell network sample
Message-ID:
        <CACwMPm8ZSJvXK7G-_RTZB02T=l8bzdunh0w1fljywlezvnb...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Not sure why you're having issues, I just tried it on GHC 7.6.3 on Fedora
20 and it worked fine there as well (both with runhaskell or compiled with
-O).

I might start adding putStrLn statements to the code to see where it's
unexpectedly blocking, or perhaps use 127.0.0.1 instead of "localhost" in
case the issue is a DNS misconfiguration.



On Tue, May 20, 2014 at 10:51 PM, yang.zhao <[email protected]> wrote:

> thanks for your replay.
> i run the two program in two different teriminal for sure.
>
> it works for you?
> but why can't run well on my computer.
>
> make me creazy....
>
>
> 2014-05-21 13:47 GMT+08:00 Bob Ippolito <[email protected]>:
>
> 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.
>>
>> It works for me here on Mac OS X 10.9.2 with GHC 7.8.2.
>>
>>
>> On Tue, May 20, 2014 at 10:42 PM, yang.zhao <[email protected]> wrote:
>>
>>> hi guys,
>>> I'm newbie, just begin to learn Haskell.
>>> now i write a very simple server and client .
>>>
>>> Server:
>>> import Control.Concurrent
>>> import System.IO
>>> import Network
>>>
>>> port :: Int
>>> port = 1234
>>>
>>> main :: IO ()
>>> main = withSocketsDo $ do
>>>     s <- listenOn $ PortNumber $ fromIntegral port
>>>     (h, _, _) <- accept s
>>>
>>>     sline <- hGetLine h
>>>     hPutStrLn h sline
>>>     putStrLn $ "send "++sline
>>>     threadDelay 1000000
>>>
>>>     hClose h
>>>     sClose s
>>>
>>> Client :
>>> import System.IO
>>> import Network
>>>
>>> port :: Int
>>> port = 1234
>>>
>>> main :: IO ()
>>> main = withSocketsDo $ do
>>>     h <- connectTo "localhost" $ PortNumber $ fromIntegral port
>>>     hPutStrLn h "hello"
>>>     bs <- hGetContents h
>>>     putStrLn bs
>>>     hClose h
>>>
>>>
>>> And, it doesn't work now . I run ./serv , then run ./cli , they will
>>> block all the time.
>>> but,  when i run ./serv, and telnet localhost 1234 in another terminal,
>>> it works fine.
>>> so i don't know what's the wrong with my code.
>>> anybody can tell me about my problem?
>>>
>>> os is Debian 7,  haskell-platform  2012.2.0.0
>>>
>>> thanks a lot!!!
>>> --
>>> K.I.S.S.
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
>
> --
> K.I.S.S.
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140520/ff48e97c/attachment-0001.html>

------------------------------

Message: 4
Date: Wed, 21 May 2014 14:10:30 +0800
From: "yang.zhao" <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Haskell network sample
Message-ID:
        <CAKXgZ3YcS1m5sLrr0f-gV4ZPKVihJ9=9b1oq1wtk5z+0xm4...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Here's my new code:

$ cat serv.hs
import Control.Concurrent
import System.IO
import Network

port :: Int
port = 1234

main :: IO ()
main = withSocketsDo $ do
    s <- listenOn $ PortNumber $ fromIntegral port
    putStrLn "Listening..."
    (h, _, _) <- accept s
    putStrLn "After accept"
    sline <- hGetLine h
    putStrLn "get line from handle"
    hPutStrLn h sline
    putStrLn $ "send "++sline
    threadDelay 1000000

    hClose h
    sClose s

--------
$ cat clie.hs
import System.IO
import Network

port :: Int
port = 1234

main :: IO ()
main = withSocketsDo $ do
    h <- connectTo "127.0.0.1" $ PortNumber $ fromIntegral port
    putStrLn "After connect"
    hPutStrLn h "hello"
    putStrLn "put hello to handle done"
    bs <- hGetContents h
    putStrLn "read from handle done"
    putStrLn bs
    hClose h


===
one terminal, run ./serv, then run ./clie in another terminal. Output is :

$ ./serv
Listening...
After accept

$ ./clie
After connect
put hello to handle done
read from handle done


it seems that client has read from then handle, but donesn't read anything,
then block.
and server donesn't receive anything, still wait for something...

ghc version is 7.4.1, because of this?..


2014-05-21 13:57 GMT+08:00 Bob Ippolito <[email protected]>:

> Not sure why you're having issues, I just tried it on GHC 7.6.3 on Fedora
> 20 and it worked fine there as well (both with runhaskell or compiled with
> -O).
>
> I might start adding putStrLn statements to the code to see where it's
> unexpectedly blocking, or perhaps use 127.0.0.1 instead of "localhost" in
> case the issue is a DNS misconfiguration.
>
>
>
> On Tue, May 20, 2014 at 10:51 PM, yang.zhao <[email protected]> wrote:
>
>> thanks for your replay.
>> i run the two program in two different teriminal for sure.
>>
>> it works for you?
>> but why can't run well on my computer.
>>
>> make me creazy....
>>
>>
>> 2014-05-21 13:47 GMT+08:00 Bob Ippolito <[email protected]>:
>>
>> 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.
>>>
>>> It works for me here on Mac OS X 10.9.2 with GHC 7.8.2.
>>>
>>>
>>> On Tue, May 20, 2014 at 10:42 PM, yang.zhao <[email protected]> wrote:
>>>
>>>> hi guys,
>>>> I'm newbie, just begin to learn Haskell.
>>>> now i write a very simple server and client .
>>>>
>>>> Server:
>>>> import Control.Concurrent
>>>> import System.IO
>>>> import Network
>>>>
>>>> port :: Int
>>>> port = 1234
>>>>
>>>> main :: IO ()
>>>> main = withSocketsDo $ do
>>>>     s <- listenOn $ PortNumber $ fromIntegral port
>>>>     (h, _, _) <- accept s
>>>>
>>>>     sline <- hGetLine h
>>>>     hPutStrLn h sline
>>>>     putStrLn $ "send "++sline
>>>>     threadDelay 1000000
>>>>
>>>>     hClose h
>>>>     sClose s
>>>>
>>>> Client :
>>>> import System.IO
>>>> import Network
>>>>
>>>> port :: Int
>>>> port = 1234
>>>>
>>>> main :: IO ()
>>>> main = withSocketsDo $ do
>>>>     h <- connectTo "localhost" $ PortNumber $ fromIntegral port
>>>>     hPutStrLn h "hello"
>>>>     bs <- hGetContents h
>>>>     putStrLn bs
>>>>     hClose h
>>>>
>>>>
>>>> And, it doesn't work now . I run ./serv , then run ./cli , they will
>>>> block all the time.
>>>> but,  when i run ./serv, and telnet localhost 1234 in another terminal,
>>>> it works fine.
>>>> so i don't know what's the wrong with my code.
>>>> anybody can tell me about my problem?
>>>>
>>>> os is Debian 7,  haskell-platform  2012.2.0.0
>>>>
>>>> thanks a lot!!!
>>>> --
>>>> K.I.S.S.
>>>>
>>>> _______________________________________________
>>>> Beginners mailing list
>>>> [email protected]
>>>> http://www.haskell.org/mailman/listinfo/beginners
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Beginners mailing list
>>> [email protected]
>>> http://www.haskell.org/mailman/listinfo/beginners
>>>
>>>
>>
>>
>> --
>> K.I.S.S.
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://www.haskell.org/mailman/listinfo/beginners
>>
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>


-- 
K.I.S.S.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20140521/7498d4b4/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 71, Issue 22
*****************************************

Reply via email to