summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/nettester.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/nettester.c b/tests/nettester.c
index b8816b7c..c9a978c5 100644
--- a/tests/nettester.c
+++ b/tests/nettester.c
@@ -107,6 +107,7 @@ tcpSend(char *buf, int lenBuf)
{
static int sock = INVALID_SOCKET;
struct sockaddr_in addr;
+ int retries;
if(sock == INVALID_SOCKET) {
/* first time, need to connect to target */
@@ -122,10 +123,19 @@ tcpSend(char *buf, int lenBuf)
fprintf(stderr, "inet_aton() failed\n");
return(1);
}
- if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) != 0) {
- fprintf(stderr, "connect() failed\n");
- return(1);
- }
+ retries = 0;
+ while(1) { /* loop broken inside */
+ if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == 0) {
+ break;
+ } else {
+ if(retries++ == 3) {
+ fprintf(stderr, "connect() failed\n");
+ return(1);
+ } else {
+ sleep(1);
+ }
+ }
+ }
}
/* send test data */