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)
51 Frame* f = (Frame*) malloc(sizeof(Frame) + mtu);
53 throw std::runtime_error("No se puede reservar memoria");
54 int res = msgrcv(que_id, f, mtu + sizeof(size_t), mac, 0);
58 throw std::runtime_error("Error al sacar de la cola");
60 std::string s((char*) f->frame, f->size);
63 std::cout << "DevQue::receive(msgtype/mac = " << mac << ", size = "
69 // vim: set et sw=4 sts=4 :