From 8c0dd44a5eec970fd0abdb856667c08cb25efae2 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 16 Nov 2007 23:14:35 +0000 Subject: [PATCH] With DEBUG on, it may require some looping to read all data git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@383 42af7a65-404d-4744-a932-0658087f49c3 --- examples/nettest/nettest-client.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/examples/nettest/nettest-client.c b/examples/nettest/nettest-client.c index cb086059c8..19e1e6c378 100644 --- a/examples/nettest/nettest-client.c +++ b/examples/nettest/nettest-client.c @@ -64,6 +64,7 @@ void send_client(void) int nbytessent; #ifndef CONFIG_EXAMPLE_NETTEST_PERFORMANCE int nbytesrecvd; + int totalbytesrecvd; #endif int ch; int i; @@ -141,24 +142,31 @@ void send_client(void) } else if (nbytessent != SENDSIZE) { - message("client: Bad send length=%d: %d\n", nbytessent); + message("client: Bad send length: %d Expected: %d\n", nbytessent, SENDSIZE); close(sockfd); exit(-1); } - message("client: Receiving...\n"); - nbytesrecvd = recv(sockfd, inbuf, SENDSIZE, 0); - message("client: Received %d bytes\n", nbytesrecvd); + totalbytesrecvd = 0; + do + { + message("client: Receiving...\n"); + nbytesrecvd = recv(sockfd, &inbuf[totalbytesrecvd], SENDSIZE - totalbytesrecvd, 0); - if (nbytesrecvd < 0) - { - message("client: recv failed: %d\n", errno); - close(sockfd); - exit(-1); + if (nbytesrecvd < 0) + { + message("client: recv failed: %d\n", errno); + close(sockfd); + exit(-1); + } + totalbytesrecvd += nbytesrecvd; + message("client: Received %d of %d bytes\n", totalbytesrecvd, SENDSIZE); } - else if (nbytesrecvd != SENDSIZE) + while (totalbytesrecvd < SENDSIZE); + + if (totalbytesrecvd != SENDSIZE) { - message("client: Bad recv length=%d: %d\n", nbytesrecvd); + message("client: Bad recv length: %d Expected: %d\n", totalbytesrecvd, SENDSIZE); close(sockfd); exit(-1); }