[Haskell-beginners] recvFrom return value different from length of resulting string

Nathan Hüsken nathan.huesken at posteo.de
Fri May 10 22:50:48 CEST 2013


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
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners




More information about the Beginners mailing list