Home | History | Annotate | Download | only in testspdy
      1 /*
      2     This file is part of libmicrospdy
      3     Copyright Copyright (C) 2012 Andrey Uzunov
      4 
      5     This program is free software: you can redistribute it and/or modify
      6     it under the terms of the GNU General Public License as published by
      7     the Free Software Foundation, either version 3 of the License, or
      8     (at your option) any later version.
      9 
     10     This program is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13     GNU General Public License for more details.
     14 
     15     You should have received a copy of the GNU General Public License
     16     along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 */
     18 
     19 /**
     20  * @file daemon_start_stop_many.c
     21  * @brief  starts and stops several SPDY daemons, reusing port numbers
     22  * @author Andrey Uzunov
     23  */
     24 
     25 #include "platform.h"
     26 #include "microspdy.h"
     27 #include "common.h"
     28 
     29 int
     30 main()
     31 {
     32 	int i;
     33 	int j;
     34 	int num_daemons = 3;
     35 	int num_tries = 5;
     36 	int port = get_port(15123);
     37 	struct SPDY_Daemon *daemon[num_daemons];
     38 
     39 	SPDY_init();
     40 
     41 	for(i=0; i<num_tries; ++i)
     42 	{
     43 		for(j=0;j<num_daemons;++j)
     44 		{
     45 			daemon[j] = SPDY_start_daemon(port + j,
     46 			DATA_DIR "cert-and-key.pem",
     47 			DATA_DIR "cert-and-key.pem",
     48 			NULL,NULL,NULL,NULL,NULL,SPDY_DAEMON_OPTION_END);
     49 
     50 			if(NULL==daemon[j]){
     51 				printf("no daemon\n");
     52 				return 1;
     53 			}
     54 		}
     55 
     56 
     57 		for(j=0;j<num_daemons;++j)
     58 		{
     59 			SPDY_stop_daemon(daemon[j]);
     60 		}
     61 	}
     62 
     63 	SPDY_deinit();
     64 
     65 	return 0;
     66 }
     67