Go to the documentation of this file.00001
00023 #ifndef UDP_BC_BROKER_RECV_H_
00024 #define UDP_BC_BROKER_RECV_H_
00025
00026 #include <iostream>
00027 #include <stdio.h>
00028 #include <vector>
00029 #include <sys/socket.h>
00030 #include <unistd.h>
00031 #include <sys/types.h>
00032 #include <netdb.h>
00033 #include <netinet/in.h>
00034 #include <arpa/inet.h>
00035 #include <string.h>
00036 #include <boost/function.hpp>
00037 #include <boost/bind.hpp>
00038 #include <boost/thread.hpp>
00039
00040 using namespace std;
00041
00042 namespace udp_bc_broker{
00043
00044 class UdpRecver {
00045 public:
00046 UdpRecver(int port);
00047 ~UdpRecver();
00048 void receive(boost::function<void(const vector<uint8_t>&)> callBack);
00049 private:
00050 void process_msg();
00051 boost::function<void(const vector<uint8_t>&)> callback;
00052 int sock;
00053 struct sockaddr_in addrto;
00054 struct sockaddr_in from;
00055 int nlen;
00056 int len;
00057 char *buf;
00058 boost::thread* process_thread_;
00059 };
00060 };
00061
00062 #endif