[Haskell-beginners] Network client - reading and writing to a socket
Manfred Lotz
manfred.lotz at arcor.de
Mon Aug 1 21:16:46 CEST 2011
On Sun, 31 Jul 2011 15:14:23 -0400
Patrick LeBoutillier <patrick.leboutillier at gmail.com> wrote:
> 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.
>
Hmm. I'm not quite sure you are fully right. On the one hand I believe
that this could be an issue which arises in python/perl etc. as well.
On the other hand I believe it should be possible to receive from a
socket what is available at a certain point of time.
I found this link http://sequence.complete.org/node/257, and when I run
the code I get the full message from the imap server even if the
message is a couple of megabytes big.
I have to figure out how to use the code for my need as I do not get
the input from the keyboard. As a haskell beginner things like this are
not always trivial.
--
Thanks,
Manfred
>
> Patrick
>
> >
> > --
> > Manfred
> >
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> >
>
>
>
--
Manfred
More information about the Beginners
mailing list