summaryrefslogtreecommitdiff
path: root/nuttx/examples/nettest
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-16 23:14:35 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-11-16 23:14:35 +0000
commita80ff427530ab32907f0d3858b05a8d4fbf13be2 (patch)
tree67a96919e7521a7dc0b992bc9b764dfd2f612dc1 /nuttx/examples/nettest
parent66fa9eb830939b33a268b24573f9fdf59850dac5 (diff)
downloadpx4-nuttx-a80ff427530ab32907f0d3858b05a8d4fbf13be2.tar.gz
px4-nuttx-a80ff427530ab32907f0d3858b05a8d4fbf13be2.tar.bz2
px4-nuttx-a80ff427530ab32907f0d3858b05a8d4fbf13be2.zip
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
Diffstat (limited to 'nuttx/examples/nettest')
-rw-r--r--nuttx/examples/nettest/nettest-client.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/nuttx/examples/nettest/nettest-client.c b/nuttx/examples/nettest/nettest-client.c
index cb086059c..19e1e6c37 100644
--- a/nuttx/examples/nettest/nettest-client.c
+++ b/nuttx/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);
-
- if (nbytesrecvd < 0)
+ totalbytesrecvd = 0;
+ do
{
- message("client: recv failed: %d\n", errno);
- close(sockfd);
- exit(-1);
+ 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);
+ }
+ 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);
}