I have a socket server that waits for input from a connection via hGetLine. This works great when messages are sent with a trailing newline ch开发者_如何学运维aracter. What I would like is to grab from the buffer whenever a newline or null character is received--Setting the handle's buffer mode to NoBuffering doesn't effect this, hGetLine still hangs until a \n shows up. Is there a simple way to accommodate both newline and null terminators?
You can probably spin your own solution using either hGetChar or hGetBufSome. I think you'd get better through-put with hGetBufSome. However, it looks like hGetBufSome is not implemented for Data.Text so you are probably stuck in System.IO.
http://hackage.haskell.org/packages/archive/base/latest/doc/html/System-IO.html#v:hGetBufSome
Good luck
精彩评论