You have two bugs.
First, this code:
result = read(conHandler, &buffer, size);
You read into the place where the address of buffer is stored rather than the buffer itself.
Second, you throw the results of read
away, so you have no idea how many bytes you read. If the code is intended to read exactly size
bytes, you need to do something like this:
int total_read = 0;
do
{
result = read(conHandle, buffer + total_read, size - total_read);
if (result <= 0) return result;
total_read += result;
}
while (total_read < result);