I am trying to read a few bytes from a socket in Haskell. Basically, I want to do something equivalent to this:
client_socket.recv(255) #(Python)
What is the best way to do this?
There's Network.Socket, which has recvFrom and recvBufFrom. The first assumes that you need a string that you certainly don't want if you want binary data. The second uses a pointer that you probably don't want to deal with. There is also socketToHandle, which is very useful.
However, my recommendation is the network-bytestring library . It supports both lazy and strict bytes. http://hackage.haskell.org/package/network-bytestring
For such novice questions, it is not a bad idea to check out RWH first.
And as a general rule, you should always look at Hackage for libraries and documentation. Hayoo and Hoogle are your friends to find a feature.