httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/test client.c
Date Sun, 19 Nov 2000 01:54:13 GMT
trawick     00/11/18 17:54:12

  Modified:    src/lib/apr/test client.c
  Log:
  The client test program now makes better use of apr_getaddrinfo(),
  calling it before apr_create_socket(), then getting the type of
  socket appropriate for the destination.
  
  Revision  Changes    Path
  1.20      +22 -20    apache-2.0/src/lib/apr/test/client.c
  
  Index: client.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/test/client.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- client.c	2000/11/18 15:46:45	1.19
  +++ client.c	2000/11/19 01:54:12	1.20
  @@ -99,32 +99,24 @@
       }
       fprintf(stdout, "OK\n");
   
  -    fprintf(stdout, "\tClient:  Creating new socket.......");
  -    if (apr_create_tcp_socket(&sock, context) != APR_SUCCESS) {
  -        fprintf(stderr, "Couldn't create socket\n");
  -        exit(-1);
  -    }
  -    fprintf(stdout, "OK\n");
  -
  -    if (read_timeout == -1) {
  -        fprintf(stdout, "\tClient:  Setting socket option NONBLOCK.......");
  -        if (apr_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) {
  -            apr_close_socket(sock);
  -            fprintf(stderr, "Couldn't set socket option\n");
  -            exit(-1);
  -        }
  -        fprintf(stdout, "OK\n");
  -    }
  -
       fprintf(stdout,"\tClient:  Making socket address...............");
  -    if (apr_getaddrinfo(&destsa, dest, APR_INET, 8021, 0, context) != APR_SUCCESS)
{
  -        apr_close_socket(sock);
  +    if ((stat = apr_getaddrinfo(&destsa, dest, APR_UNSPEC, 8021, 0, context)) 
  +        != APR_SUCCESS) {
           fprintf(stdout, "Failed!\n");
  -        fprintf(stdout, "Couldn't create a socket address structure for %s\n", dest);
  +        fprintf(stdout, "Address resolution failed for %s: %s\n", 
  +                dest, apr_strerror(stat, msgbuf, sizeof(msgbuf)));
           exit(-1);
       }
       fprintf(stdout,"OK\n");
   
  +    fprintf(stdout, "\tClient:  Creating new socket.......");
  +    if (apr_create_socket(&sock, destsa->sa.sin.sin_family, SOCK_STREAM,
  +                          context) != APR_SUCCESS) {
  +        fprintf(stderr, "Couldn't create socket\n");
  +        exit(-1);
  +    }
  +    fprintf(stdout, "OK\n");
  +
       fprintf(stdout, "\tClient:  Connecting to socket.......");
   
       stat = apr_connect(sock, destsa);
  @@ -137,6 +129,16 @@
           exit(-1);
       }
       fprintf(stdout, "OK\n");
  +
  +    if (read_timeout == -1) {
  +        fprintf(stdout, "\tClient:  Setting socket option NONBLOCK.......");
  +        if (apr_setsocketopt(sock, APR_SO_NONBLOCK, 1) != APR_SUCCESS) {
  +            apr_close_socket(sock);
  +            fprintf(stderr, "Couldn't set socket option\n");
  +            exit(-1);
  +        }
  +        fprintf(stdout, "OK\n");
  +    }
   
       apr_get_ipaddr(&remote_ipaddr, APR_REMOTE, sock);
       apr_get_port(&remote_port, APR_REMOTE, sock);
  
  
  

Mime
View raw message