camille/QNX-test-project — comment on commit d81323b52f9b3b2a300aae39c599cb0896250117
File:  line 0
By camille:

#include
#include
#include
#include
#include
#include
#include
#include
#include

int main() {

struct timespec horloge;
clock_gettime(CLOCK_REALTIME,&horloge);

struct timespec horlogeInit;
clock_gettime(CLOCK_REALTIME,&horlogeInit);
int Debut= horloge.tv_sec;
int Courant= horloge.tv_sec;
int Duree=Courant-Debut;

int erreur=0;
int errvalue;
int chid;
int* itemp;

char *smsg = "This is the outgoing buffer";
char rmsg [200];
char message [512];

pid_t processusFils; //recoit l'heure et l'affiche --serveur
pid_t processusPere; //envoie l'heure a intervalle régulier --client

processusFils=getpid();
setprio(getpid(),10);
processusPere = fork();

if (processusPere) {
chid = ChannelCreate(1);
printf("pid pere : %d\n",getpid());
int mes=-1;
int antecedenmes=0;
antecedenmes=mes;
while (1) {
int rcvid=MsgReceive(1,&mes,sizeof(int),NULL); //on recoit un message ,arg1=chid
if (antecedenmes !=mes) {
printf("nombre de secondes :%d\n",mes);
antecedenmes=mes;
}
MsgReply(rcvid,EOK,NULL,0); // on renvoie un message vide
}
}

else {
printf("pid fils : %d \n",getpid());
int coid =ConnectAttach(0,getppid(),1,0,0);
errvalue = errno;
printf( "The error (ConnectAttach) generated was %d\n", errvalue );
printf( "That means (ConnectAttach) : %s\n", strerror( errvalue ) );
Debut= horlogeInit.tv_sec;

int reponse=0;
while (1) {
Courant= horloge.tv_sec;
clock_gettime(CLOCK_REALTIME,&horloge);
Duree=Courant-Debut;
//	printf("valeur de duree %d\n",Duree);
if (MsgSend(coid,&Duree,sizeof(int),reponse,sizeof (int)) && erreur==0) {
erreur=1;
printf("Erreur durant l'envoie du message\n");
errvalue = errno;
printf( "The error (MsgSend) generated was %d\n", errvalue );
printf( "That means (MsgSend) : %s\n", strerror( errvalue ) );
}
else {
//	printf("message envoye");
}
}
}
return 0;
}