diff options
Diffstat (limited to 'tests/nettester.c')
-rw-r--r-- | tests/nettester.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/nettester.c b/tests/nettester.c index b8816b7c..dbfb4db3 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,20 @@ 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++ == 30) { + ++iFailed; + fprintf(stderr, "connect() failed\n"); + return(1); + } else { + usleep(100); + } + } + } } /* send test data */ |