[Haskell-beginners] Network client - reading and writing to a socket

Manfred Lotz manfred.lotz at arcor.de
Sun Jul 31 18:17:25 CEST 2011


On Sun, 31 Jul 2011 12:02:16 -0400
David Place <d at vidplace.com> wrote:

> 
> On Jul 31, 2011, at 11:39 AM, Manfred Lotz wrote:
> 
> > How could I force to get the whole message?
> 
> Did you try hFlush?
> 
> 

I tried it like this

recvMsg :: Handle -> IO B.ByteString 
recvMsg h = do
  c <- B.hGet h 1
  hFlush h
  c' <- B.hGetNonBlocking h 40000 
  return $ B.concat [c,c']


and it didn't help. Still an incomplete message.


-- 
Manfred





More information about the Beginners mailing list