void DevTCP::transmit(const std::string& data, const mac_type& mac)
throw (std::runtime_error, std::logic_error)
{
+#ifdef DEBUG_TRACE
+ std::cout << "DevTCP[" << port << "]::transmit()\n";
+#endif
if (data.size() > mtu)
throw std::logic_error("Tamaño de datos mayor al MTU");
if (tx_pool.find(mac) == tx_pool.end()) // No existe la conexión
{
std::string addr = IPAddr(mac);
-#ifdef DEBUG2
+#ifdef DEBUG_QUE
std::cout << "DevTCP::transmit: conectando a " << addr << ":" << port << "\n";
#endif
tx_pool[mac] = libtcp_open_activo(addr.c_str(), port);
size_t size = data.size();
if (libtcp_send(tx_pool[mac], &size, sizeof(size_t)) != sizeof(size_t))
throw std::runtime_error("Error al enviar por el socket");
- if ((unsigned)libtcp_send(tx_pool[mac], data.c_str(), data.size()) != data.size())
+ if ((unsigned)libtcp_send(tx_pool[mac], data.data(), data.size()) != data.size())
throw std::runtime_error("Error al enviar por el socket");
-#ifdef DEBUG2
+#ifdef DEBUG_QUE
std::cout << "DevTCP::transmit(mac = " << mac << ", size = "
<< data.size() << ")\n";
#endif
std::string DevTCP::receive() throw (std::runtime_error)
{
+#ifdef DEBUG_TRACE
+ std::cout << "DevTCP[" << port << "]::receive()\n";
+#endif
// Nos fijamos en todos los file descriptors si hay algo para nosotros.
while (true)
{
- int res = poll(pfds, pfds_size, 5000);
+ int res = poll(pfds, pfds_size, -1);
if (res == -1)
throw std::runtime_error("Error al hacer poll");
if (!res)
continue;
std::string ret(buf, size);
free(buf);
-#ifdef DEBUG2
+#ifdef DEBUG_QUE
std::cout << "DevTCP::receive(msgtype/mac = " << mac << ", size = "
<< ret.size() << ")\n";
#endif