From 5be15863d38b173a11af3a6543fef94c92f7256c Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 6 Mar 2006 15:29:19 +0000 Subject: [PATCH] --- src/highreceiver.cc | 31 ++++++++++++++++++++++++++++--- src/lowreceiver_cb.cc | 4 +++- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/highreceiver.cc b/src/highreceiver.cc index 34b67a3..b9e9c17 100644 --- a/src/highreceiver.cc +++ b/src/highreceiver.cc @@ -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... } } diff --git a/src/lowreceiver_cb.cc b/src/lowreceiver_cb.cc index cbe35a8..ccc4a5f 100644 --- a/src/lowreceiver_cb.cc +++ b/src/lowreceiver_cb.cc @@ -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); } }