Haskell hGetLine and null character

I have a socket server that is waiting for input from a connection through hGetLine. This works great when messages are sent with a trailing newline. I would like to grab from the buffer whenever a newline or zero is received - setting the descriptor's buffer mode to NoBuffering does not affect this, hGetLine still hangs until \ n appears. Is there an easy way to post both new and null terminators?

+4
source share
1 answer

Perhaps you can use your own solution using hGetChar or hGetBufSome. I think you will be better off using hGetBufSome. However, it seems that 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.

+1
source

Source: https://habr.com/ru/post/1341864/


All Articles