[Haskell-beginners] Network client - reading and writing to a socket
Patrick LeBoutillier
patrick.leboutillier at gmail.com
Sun Jul 31 21:14:23 CEST 2011
Manfred,
> The problem is that the message itself is some 30K big and I only
> get some 16K of the message.
>
> How could I force to get the whole message?
My guess is that you can't. This call:
c' <- B.hGetNonBlocking h 40000
tries to read as much as it can (up to 40000 bytes) but it won't block
to wait for data. Perhaps the rest of your message is in a different
TCP packet or delayed or whatever, but I think you have to keep on
reading (and maybe block) until you know you have read the entire
message. The IMAP specs will tell you how to identify the "end of the
message".
BTW: This issue is not Haskell specific. If you implement the same
code in C, Perl or Java you will have to deal with the same problem.
When you read from a socket, there is no general way of knowing that
the other side has sent everything.
Patrick
>
> --
> Manfred
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
--
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada
More information about the Beginners
mailing list