19 DevQue::DevQue(mac_type mac, key_t key, size_t mtu)
20 throw (std::runtime_error, std::logic_error):
23 que_id = msgget(key, 0666); // Debe estar previamente creada
25 throw std::runtime_error("No se pudo crear la cola");
28 void DevQue::transmit(const std::string& data, const mac_type& mac)
29 throw (std::runtime_error, std::logic_error)
31 if (data.size() > mtu)
32 throw std::logic_error("Tamaño de datos mayor al MTU");
33 Frame* f = (Frame*) malloc(sizeof(Frame) + mtu);
35 throw std::runtime_error("No se puede reservar memoria");
37 f->size = data.size();
38 memcpy(f->frame, data.c_str(), data.size());
39 int res = msgsnd(que_id, f, mtu + sizeof(size_t), 0);
41 std::cout << "DevQue::transmit(msgtype/mac = " << f->mac << ", size = "
46 throw std::runtime_error("Error al poner en la cola");
49 std::string DevQue::receive() throw (std::runtime_error)
54 std::string DevQue::receive(const mac_type& mac) throw (std::runtime_error)
56 Frame* f = (Frame*) malloc(sizeof(Frame) + mtu);
58 throw std::runtime_error("No se puede reservar memoria");
59 int res = msgrcv(que_id, f, mtu + sizeof(size_t), mac, 0);
63 throw std::runtime_error("Error al sacar de la cola");
65 std::string s((char*) f->frame, f->size);
68 std::cout << "DevQue::receive(msgtype/mac = " << mac << ", size = "
74 // vim: set et sw=4 sts=4 :