#define DATA_SIZE 1014
char oscgram[DATA_SIZE];
char *buf = oscgram;
int brem = DATA_SIZE; /* number of bytes to read */
int r;
/* osc is file descriptor, open()'ing is omitted */
while (1) {
r = read(osc, buf, brem);
if (-1 == r) {
perror("read()");
break;
}
if (!r) {
printf("something went wrong...\n");
break;
}
brem -= r;
if (!brem)
break;
buf += r;
}