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. recvFrom return value different from length of resulting
string (Nathan H?sken)
2. Re: recvFrom return value different from length of resulting
string (Nathan H?sken)
3. Read file from sys (Libor Wagner)
----------------------------------------------------------------------
Message: 1
Date: Fri, 10 May 2013 18:34:10 +0200
From: Nathan H?sken <[email protected]>
Subject: [Haskell-beginners] recvFrom return value different from
length of resulting string
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hey,
I am trying to write a small haskell application which forwards udp
messages. The complete program is here: http://hpaste.org/87681
Notice the lines:
43 (msg,bytes,addr) <- recvFrom sock 1024
44 putStrLn $ "Received: " ++ show bytes ++ " = " ++ (show . length $ msg)
If I understand correctly, bytes is the number of bytes in the message.
This should be ?quivalent to (length msg), correct?
Now I send an udp message (by connecting over the forwarded port with
enet), and get this output:
Received: 52 = 41
than I run it again, and get this output:
Received: 52 = 43
Why is the length of msg not equal to 52?
And why is it different from run to run?
enet is unable to connect over this forward, by the way.
Thanks!
Nathan
------------------------------
Message: 2
Date: Fri, 10 May 2013 22:50:48 +0200
From: Nathan H?sken <[email protected]>
Subject: Re: [Haskell-beginners] recvFrom return value different from
length of resulting string
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
It works when I am using Network.Socket.ByteString.
I assume this is because the other recvFrom encodes the message with
peekCStringLen, but I am not sure.
Should the 2 implementations not behave the same besides returning a
different datastructure for the received data??
On 05/10/2013 06:34 PM, Nathan H?sken wrote:
> Hey,
>
> I am trying to write a small haskell application which forwards udp
> messages. The complete program is here: http://hpaste.org/87681
>
> Notice the lines:
>
> 43 (msg,bytes,addr) <- recvFrom sock 1024
> 44 putStrLn $ "Received: " ++ show bytes ++ " = " ++ (show . length $ msg)
>
> If I understand correctly, bytes is the number of bytes in the message.
> This should be ?quivalent to (length msg), correct?
>
> Now I send an udp message (by connecting over the forwarded port with
> enet), and get this output:
>
> Received: 52 = 41
>
> than I run it again, and get this output:
>
> Received: 52 = 43
>
> Why is the length of msg not equal to 52?
> And why is it different from run to run?
>
> enet is unable to connect over this forward, by the way.
>
> Thanks!
> Nathan
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
------------------------------
Message: 3
Date: Sat, 11 May 2013 11:10:41 +0200
From: Libor Wagner <[email protected]>
Subject: [Haskell-beginners] Read file from sys
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi,
I have small code snippet to read content of a file, which should grow into
simple tool to read temperature from sensor on Raspberry Pi:
module Main where
import System.Environment
main :: IO ()
main = do
[f] <- getArgs
s <- readFile f
putStr s
When this is called with the test file I have copied from the real location it
works fine:
$ cat /sys/bus/w1/devices/28-000004e46240/w1_slave >test.txt
$ ./ds18b20 test.txt
53 01 4b 46 7f ff 0d 10 e9 : crc=e9 YES
53 01 4b 46 7f ff 0d 10 e9 t=21187
How ever when called with the real location nothing happens:
$ ./ds18b20 /sys/bus/w1/devices/28-000004e46240/w1_slave
Can someone help? I have thought that the file is not properly ended so I have
tried to take just first line but that doest work either.
Thanks
Libor
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 59, Issue 10
*****************************************