#include "plaqui/server/transmitter.h"
#include <socket++/sockinet.h>
#include <string>
+#ifdef DEBUG
+# include <iostream>
+#endif // DEBUG
-using namespace Plaqui;
+using namespace std;
-Transmitter::Transmitter(std::string host, int port):
+namespace PlaQui {
+
+namespace Server {
+
+Transmitter::~Transmitter(void) {
+#ifdef DEBUG
+ cerr << __FILE__ << ": destructor." << endl;
+#endif // DEBUG
+}
+
+/// \todo debría conectarse en real_run() (?)
+Transmitter::Transmitter(string host, int port):
Connection(sockbuf::sock_dgram) {
+#ifdef DEBUG
+ cerr << __FILE__ << ": host = " << host
+ << " | port = " << port << endl;
+#endif // DEBUG
// FIXME - deberia ir en run().
socket->connect(host.c_str(), port);
}
+/// \todo debría dar una excepción (?)
void Transmitter::real_run(void) {
+#ifdef DEBUG
// FIXME - debería tirar una excepción?
if (!socket->is_open()) {
- std::cerr << "No se pudo conectar a " << socket->peerhost() <<
- ":" << socket->peerport() << "." << std::endl;
+ cerr << "No se pudo conectar a " << socket->peerhost() <<
+ ":" << socket->peerport() << "." << endl;
} else {
- std::cerr << "Conectado a " << socket->peerhost() <<
- ":" << socket->peerport() << "." << std::endl;
+ cerr << "Conectado a " << socket->peerhost() <<
+ ":" << socket->peerport() << "." << endl;
}
+#endif // DEBUG
}
+} // namespace Server
+
+} // namespace PlaQui
+