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

appli.cpp File Reference

#include "total_order_channel.h"
#include <pthread.h>
#include <iostream.h>
#include <unistd.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

int main (int argc, char* argv[])
void receive ( char * message, int size )

Variables

int cur = 0
int last = 0
pthread_mutex_t mumute
char message [500]


Function Documentation

int main (int argc, char * argv[])

Definition at line 12 of file appli.cpp.

00012 {
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 }

void receive (char * message, int size)

Definition at line 63 of file appli.cpp.

00063 {
00064 
00065         cout << " HELLO  message recu: " << message << endl;
00066 
00067         }

Variable Documentation

int cur = 0

Definition at line 8 of file appli.cpp.

int last = 0

Definition at line 9 of file appli.cpp.

char message[500]

Definition at line 11 of file appli.cpp.

pthread_mutex_t mumute

Definition at line 10 of file appli.cpp.


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