diff --git a/src/sptps_speed.c b/src/sptps_speed.c index 4cb1221b..4d112dd7 100644 --- a/src/sptps_speed.c +++ b/src/sptps_speed.c @@ -47,11 +47,16 @@ static bool receive_record(void *handle, uint8_t type, const void *data, uint16_ } static void receive_data(sptps_t *sptps) { - char buf[4096]; + char buf[4096], *bufp = buf; int fd = *(int *)sptps->handle; size_t len = recv(fd, buf, sizeof buf, 0); - if(!sptps_receive_data(sptps, buf, len)) - abort(); + while(len) { + size_t done = sptps_receive_data(sptps, bufp, len); + if(!done) + abort(); + bufp += done; + len -= done; + } } struct timespec start; diff --git a/src/sptps_test.c b/src/sptps_test.c index f83307fe..9452ed1e 100644 --- a/src/sptps_test.c +++ b/src/sptps_test.c @@ -357,8 +357,19 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Dropped.\n"); continue; } - if(!sptps_receive_data(&s, buf, len) && !datagram) - return 1; + char *bufp = buf; + while(len) { + size_t done = sptps_receive_data(&s, bufp, len); + if(!done) { + if(!datagram) + return 1; + } else { + break; + } + + bufp += done; + len -= done; + } } }