Network backend: Close the socket when destroying the network context

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Network backend: Prevent warnings when building on a 32-bit system

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Network backend: Fix calls to strerror with negative values

Additionally, strerror_r now replaces strerror in the error
messages; strerror is not thread-safe and thus should not be used
in this library.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Network backend: Added helper function read_integer

This function can be used to read the error codes and integer
values sent by the IIOD server.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
Network backend: Added ops to read/write device attributes

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
IIOD: Added a "READBUF" command to read raw stream from devices

When receiving this command, the server will put the client's
thread in a thread pool corresponding to the device to be read.
Then, another thread will read data from the IIO device using the
libiio API, and stream the data to every connected client.

This mechanism is necesary, as only one process can access an IIO
device at the same time (with the local backend).

The server streams to every connected client one or more frames.
Each frame starts by a number (in ASCII), corresponding either to
an error code if negative, or to the number of bytes of raw data
contained in this frame. After the number comes a carriage return,
then the aforementioned amount of bytes of raw data if no error
is reported.

The stream will contain one or more successive frames, until the
amount of data asked with the "READBUF" command is reached. You
are then assured to obtain the amount of data requested, unless
one of the frames contains an error code; in that case, no further
data is sent, and the hand returns to the command interpreter.

Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>