summaryrefslogtreecommitdiff
path: root/tests/tcpflood.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2010-02-24 20:31:30 +0100
committerMichael Biebl <biebl@debian.org>2010-02-24 20:31:30 +0100
commit98a45d0b54c09ca82b3540491915ad6cc61c1a97 (patch)
tree0ec782ee7d1097acfdf2962b3b9b3404db314002 /tests/tcpflood.c
parentb743785de633f7ff5c39f980496d359e4758ec83 (diff)
downloadrsyslog-98a45d0b54c09ca82b3540491915ad6cc61c1a97.tar.gz
Imported Upstream version 4.6.0upstream/4.6.0
Diffstat (limited to 'tests/tcpflood.c')
-rw-r--r--tests/tcpflood.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index 2ca796c..0439e33 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -61,6 +61,7 @@ int openConn(int *fd)
{
int sock;
struct sockaddr_in addr;
+ int retries = 0;
if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
perror("socket()");
@@ -74,11 +75,19 @@ int openConn(int *fd)
fprintf(stderr, "inet_aton() failed\n");
return(1);
}
- if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) != 0) {
- perror("connect()");
- fprintf(stderr, "connect() failed\n");
- return(1);
- }
+ while(1) { /* loop broken inside */
+ if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == 0) {
+ break;
+ } else {
+ if(retries++ == 50) {
+ perror("connect()");
+ fprintf(stderr, "connect() failed\n");
+ return(1);
+ } else {
+ usleep(100000); /* ms = 1000 us! */
+ }
+ }
+ }
*fd = sock;
return 0;