I'm reading/writing data off of a named pipe. On the writing side it says that it's writing a constant 110 bytes. On the Reading side for the majority of time it says that it's reading 110 bytes which is correct, but other times it says its reading 220 bytes or 330 bytes. Which is right in the fact that when I print it out it's printing out the same message two or three times in a row within the same read(). In the code below for reading am I doing something wrong with the memset to clear the char? I can't think of any other way it's reading more then is being written unless something is left over in the buffer.
int fd1, numread;
char bufpipe[5000];
while(1)
{
fd1 = open("/tmp/testPipe", O_RDONLY);
numread = read(fd1,bufpipe, 5000);//->this should always be 110
if(numread > 1)
{
printf("READ: %i", numread);
bufpipe[numread+1] = '\0';
memset(bufpipe,'\0',5001);
close(fd1);
}
}