@@ -306,6 +306,7 @@ apr_port_t port; /* port number */
306306char proxyhost [1024 ]; /* proxy host name */
307307int proxyport = 0 ; /* proxy port */
308308const char * connecthost ;
309+ const char * myhost ;
309310apr_port_t connectport ;
310311const char * gnuplot ; /* GNUplot file */
311312const char * csvperc ; /* CSV Percentile file */
@@ -370,6 +371,7 @@ apr_pool_t *cntxt;
370371
371372apr_pollset_t * readbits ;
372373
374+ apr_sockaddr_t * mysa ;
373375apr_sockaddr_t * destsa ;
374376
375377#ifdef NOT_ASCII
@@ -1201,6 +1203,10 @@ static void start_connect(struct connection * c)
12011203 apr_err ("socket" , rv );
12021204 }
12031205
1206+ if ((rv = apr_socket_bind (c -> aprsock , mysa )) != APR_SUCCESS ) {
1207+ apr_err ("bind" , rv );
1208+ }
1209+
12041210 c -> pollfd .desc_type = APR_POLL_SOCKET ;
12051211 c -> pollfd .desc .s = c -> aprsock ;
12061212 c -> pollfd .reqevents = 0 ;
@@ -1699,6 +1705,14 @@ static void test(void)
16991705#endif /* NOT_ASCII */
17001706
17011707 /* This only needs to be done once */
1708+ if ((rv = apr_sockaddr_info_get (& mysa , myhost , APR_UNSPEC , 0 , 0 , cntxt )) != APR_SUCCESS ) {
1709+ char buf [120 ];
1710+ apr_snprintf (buf , sizeof (buf ),
1711+ "apr_sockaddr_info_get() for %s" , myhost );
1712+ apr_err (buf , rv );
1713+ }
1714+
1715+ /* This too */
17021716 if ((rv = apr_sockaddr_info_get (& destsa , connecthost , APR_UNSPEC , connectport , 0 , cntxt ))
17031717 != APR_SUCCESS ) {
17041718 char buf [120 ];
@@ -1857,6 +1871,7 @@ static void usage(const char *progname)
18571871 fprintf (stderr , " -c concurrency Number of multiple requests to make\n" );
18581872 fprintf (stderr , " -t timelimit Seconds to max. wait for responses\n" );
18591873 fprintf (stderr , " -b windowsize Size of TCP send/receive buffer, in bytes\n" );
1874+ fprintf (stderr , " -B address Address to bind to when making outgoing connections\n" );
18601875 fprintf (stderr , " -p postfile File containing data to POST. Remember also to set -T\n" );
18611876 fprintf (stderr , " -u putfile File containing data to PUT. Remember also to set -T\n" );
18621877 fprintf (stderr , " -T content-type Content-type header for POSTing, eg.\n" );
@@ -2051,8 +2066,10 @@ int main(int argc, const char * const argv[])
20512066 }
20522067#endif
20532068
2069+ myhost = NULL ; /* 0.0.0.0 or :: */
2070+
20542071 apr_getopt_init (& opt , cntxt , argc , argv );
2055- while ((status = apr_getopt (opt , "n:c:t:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:Sq "
2072+ while ((status = apr_getopt (opt , "n:c:t:b:T:p:u:v:rkVhwix:y:z:C:H:P:A:g:X:de:SqB: "
20562073#ifdef USE_SSL
20572074 "Z:f:"
20582075#endif
@@ -2212,6 +2229,9 @@ int main(int argc, const char * const argv[])
22122229 case 'V' :
22132230 copyright ();
22142231 return 0 ;
2232+ case 'B' :
2233+ myhost = apr_pstrdup (cntxt , opt_arg );
2234+ break ;
22152235#ifdef USE_SSL
22162236 case 'Z' :
22172237 ssl_cipher = strdup (opt_arg );
0 commit comments