- Se mejora Command::build().
*
* \param type Tipo de socket a usar.
*/
- Connection(const sockbuf::type& type);
+ Connection(const sockbuf::type& type, const std::string& host,
+ const Port& port);
/**
* Constructor.
// Atributos.
- private:
-
- /// Host al cual conectarse.
- std::string host;
-
- /// Puerto al cual conectarse.
- int port;
-
protected:
/// Señal para indicar que se conectó.
* control.
* \param port Puerto al cual conectarse.
*/
- ControlClient(std::string host = "localhost", int port = 7522);
+ ControlClient(const std::string& host = "localhost",
+ const Connection::Port& port = 7522);
/**
* Envía un comando al servidor.
}
void Command::add_arg(const unsigned& arg) {
+#ifdef DEBUG
+ cerr << __FILE__ << ": add_arg(arg = " << arg << ") = "
+ << String().from(arg) << endl;
+#endif // DEBUG
args.push_back(String().from(arg));
build();
}
#endif // DEBUG
}
-Connection::Connection(const sockbuf::type& type):
- socket(type) {
+Connection::Connection(const sockbuf::type& type, const std::string& host,
+ const Port& port): socket(type), host(host), port(port) {
#ifdef DEBUG
- cerr << __FILE__ << ": type = " << type << endl;
+ cerr << __FILE__ << ": type = " << type << " | host = " << host
+ << " | port = " << port << endl;
#endif // DEBUG
}
#endif // DEBUG
}
-ControlClient::ControlClient(string host, int port):
- Connection(sockbuf::sock_stream), host(host), port(port) {
+ControlClient::ControlClient(const string& host, const Connection::Port& port):
+ Connection(sockbuf::sock_stream, host, port) {
#ifdef DEBUG
cerr << __FILE__ << ": host = " << host
<< " | port = " << port << endl;
finish();
return;
}
- host = socket->peerhost();
- port = socket->peerport();
+ host = socket->localhost();
+ port = socket->localport();
// TODO sacar a la mierda?
connected();
while (!stop) {