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

Nathan Hüsken nathan.huesken at posteo.de
Fri May 10 18:34:10 CEST 2013


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



More information about the Beginners mailing list