Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

appli.cpp

Go to the documentation of this file.
00001 #include "total_order_channel.h"
00002 #include <pthread.h>
00003 #include <iostream.h>
00004 #include <unistd.h>
00005 #include <stdlib.h>
00006 
00007         
00008 int cur = 0;
00009 int last = 0;  
00010 pthread_mutex_t  mumute;
00011 char message[500];
00012 int main(int argc, char* argv[]) {
00013 //programme de test de la classe total_order_channel
00014 
00015   
00016         int i, j, k, opt, res;
00017         char * ch;
00018         
00019         char * file, * ipadd;
00020 
00021         int ident, nb_iter, nb_members;
00022         total_order_channel * com;
00023   
00024         if(argc!=5) {
00025         
00026                 cout << " Parametre incorrects:  appli opt ipadd file nb_iteration " << endl;
00027                 return(-1);
00028         }
00029         cout << "depart appli" << endl;
00030         
00031         opt =atoi(argv[1]);   // 0: initialiser a partir de fichier , 1: s'inscrire aupres de membre
00032         ipadd = argv[2];        // si flag = 0 : numero d'ident, si flag = 1 :adresse ip[15]
00033         file = argv[3] ;        // si flag = 0 : liste de triplets, si flag = 1 : ( port, host)
00034         nb_iter = atoi(argv[4]);
00035         
00036         com = new total_order_channel(opt , file , ipadd) ;   
00037         cout << "ds l'appli apres le constructeur" << endl;
00038 
00039 
00040         sprintf(message, " *** numero  ");
00041 
00042         j=strlen(message);
00043 
00044         for(i=0; i<nb_iter ; i++) {
00045                 sprintf(&message[j], "%d !!!!!!!! ***", i);
00046                 cout << "envoi n* " << i << endl ;
00047                 
00048                 res = com->broadcast(message, strlen(message));
00049                 if ( i % 12 == 0 ) sleep( 1); 
00050                 // if ( i % 3 == 0 ) for ( k=0 ; k< 1000*nb_iter ;k++) ; 
00051                 
00052                 if( res == -2) { 
00053                         i--; sleep( 1); }
00054         }
00055   
00056         sleep( 40);
00057         pthread_join(NULL, NULL);
00058   
00059         cout << "Fin du prog de test" << endl;
00060   
00061 }
00062 
00063 void receive( char * message, int size ) {
00064 
00065         cout << " HELLO  message recu: " << message << endl;
00066 
00067         }
00068 
00069         
00070 
00071         

Generated at Mon Mar 1 18:05:54 2004 for Groupware by doxygen 1.1.1 written by Dimitri van Heesch, © 1997-2000