Reads data from the socket connection into the incoming data buffer.
It reads as much as possible from the socket connection. This returns
amount of bytes read or -1 on error or -2 on case where all of the
data could not be read at once. Implementation of this function
may be platform specific.