This commit is contained in:
parent
2063898739
commit
5be15863d3
2 changed files with 31 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "macros.h"
|
||||
#include "highreceiver.h"
|
||||
#include "message.h"
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
|
@ -54,10 +55,34 @@ HighReceiver::~HighReceiver(){
|
|||
delete _socket_addr;
|
||||
}
|
||||
|
||||
void HighReceiver::run(){
|
||||
void HighReceiver::run() {
|
||||
int buffer_len = 1500;
|
||||
char * buffer = new char[buffer_len];
|
||||
struct sockaddr_in repaddr;
|
||||
socklen_t sockaddr_len = sizeof(struct sockaddr_in);
|
||||
Message * mesg = NULL;
|
||||
while(1){
|
||||
sleep(1);
|
||||
pDEBUG(" ");
|
||||
// recevoir les données
|
||||
memset(buffer, '\0', buffer_len);
|
||||
bzero(&repaddr,sizeof(struct sockaddr_in));
|
||||
int read_buffer_len = recvfrom(
|
||||
_socket_desc,
|
||||
buffer,
|
||||
buffer_len,
|
||||
0,
|
||||
(struct sockaddr*)&repaddr,
|
||||
&sockaddr_len);
|
||||
|
||||
mesg = new Message(buffer, read_buffer_len);
|
||||
printf("HighReceiver::run -- READ size %d\n", read_buffer_len);
|
||||
char * str = new char[mesg->getDataSize() + 1];
|
||||
strncpy(str, mesg->getData(), mesg->getDataSize());
|
||||
str[mesg->getDataSize()] = '\0';
|
||||
printf("HighReceiver::run -- READ '%s'\n", str);
|
||||
|
||||
delete(mesg);
|
||||
mesg = NULL;
|
||||
// on dispatche les données en fonction du protocole...
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,9 @@ void LowReceiver::manage_cbcast(Message * mesg) {
|
|||
// on POP_FRONT et on send...
|
||||
Message * deliverableMsg = fifo_deliverable.front();
|
||||
fifo_deliverable.pop_front();
|
||||
//FIXME: délivrer
|
||||
|
||||
// délivrer "pour de vrai"
|
||||
this->deliver(deliverableMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue