Loading sls/trunk/BUGS 0 → 100644 +0 −0 Empty file added. sls/trunk/TODO +0 −4 Original line number Diff line number Diff line Gerer les control-C sur les sockets. Le server ne ferme pas la connection... Implementer un conn id pour qu'un serveur puisse numeroter les connecxions sls/trunk/src/client.cc +8 −3 Original line number Diff line number Diff line Loading @@ -35,7 +35,13 @@ Client *Client::login(Connection &c) { return login_fail(c); if (sscanf(slogin.c_str(), "HOST %512s\n", loginbuf) == 1) { std::cout << "Host " << loginbuf << " logged from " << c.getremoteip() // check login and password // Register login and pass in client // Print succefful login std::cout << "Connection id " << c.getid() << ": Host " << loginbuf << " logged from " << c.getremoteip() << " on port " << c.getremoteport() << ".\n"; return new Daemon(c); } Loading @@ -47,8 +53,7 @@ Client *Client::login(Connection &c) { } Client *Client::login_fail(Connection &c) { std::cout << "Bad authentification from " << c.getremoteip() << " on port " << c.getremoteport() << ".\n"; std::cout << "Connection id " << c.getid() << ": Bad authentification.\n"; c.sendln("Bad authentification."); return 0; } Loading sls/trunk/src/client_daemon.cc +4 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ Daemon::Daemon(Connection &c) : Client(c) {} void Daemon::exec() { // send scripts // starting scripts c_.sendln("EXIT"); while (1) { c_.sendln("toto"); } } sls/trunk/src/connection.cc +16 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,14 @@ #include <errno.h> #include <poll.h> /******************************************************************************* ** Class method ******************************************************************************/ unsigned long int Connection::getconnid() { static unsigned long int id = 1; return id++; } /******************************************************************************* ** Public method ******************************************************************************/ Loading @@ -36,14 +44,16 @@ * * @param fd socket of the connection (-1) is not exist */ Connection::Connection(int fd) : socket_fd_(fd), local_port_(-1), remote_port_(-1) { Connection::Connection(int fd) : socket_fd_(fd), local_port_(-1), remote_port_(-1), id_(0) { pthread_mutex_init(&c_mutex_, 0); pthread_mutex_init(&r_mutex_, 0); pthread_mutex_init(&w_mutex_, 0); if (socket_fd_ >= 0) if (socket_fd_ >= 0) { id_ = getconnid(); setallinfo_(); } } /** * Destructor Loading Loading @@ -352,6 +362,10 @@ int Connection::getremoteport() { return port; } unsigned long int Connection::getid() { return id_; } int Connection::getsocket() { pthread_mutex_lock(&c_mutex_); int ret = socket_fd_; Loading Loading
sls/trunk/TODO +0 −4 Original line number Diff line number Diff line Gerer les control-C sur les sockets. Le server ne ferme pas la connection... Implementer un conn id pour qu'un serveur puisse numeroter les connecxions
sls/trunk/src/client.cc +8 −3 Original line number Diff line number Diff line Loading @@ -35,7 +35,13 @@ Client *Client::login(Connection &c) { return login_fail(c); if (sscanf(slogin.c_str(), "HOST %512s\n", loginbuf) == 1) { std::cout << "Host " << loginbuf << " logged from " << c.getremoteip() // check login and password // Register login and pass in client // Print succefful login std::cout << "Connection id " << c.getid() << ": Host " << loginbuf << " logged from " << c.getremoteip() << " on port " << c.getremoteport() << ".\n"; return new Daemon(c); } Loading @@ -47,8 +53,7 @@ Client *Client::login(Connection &c) { } Client *Client::login_fail(Connection &c) { std::cout << "Bad authentification from " << c.getremoteip() << " on port " << c.getremoteport() << ".\n"; std::cout << "Connection id " << c.getid() << ": Bad authentification.\n"; c.sendln("Bad authentification."); return 0; } Loading
sls/trunk/src/client_daemon.cc +4 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ Daemon::Daemon(Connection &c) : Client(c) {} void Daemon::exec() { // send scripts // starting scripts c_.sendln("EXIT"); while (1) { c_.sendln("toto"); } }
sls/trunk/src/connection.cc +16 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,14 @@ #include <errno.h> #include <poll.h> /******************************************************************************* ** Class method ******************************************************************************/ unsigned long int Connection::getconnid() { static unsigned long int id = 1; return id++; } /******************************************************************************* ** Public method ******************************************************************************/ Loading @@ -36,14 +44,16 @@ * * @param fd socket of the connection (-1) is not exist */ Connection::Connection(int fd) : socket_fd_(fd), local_port_(-1), remote_port_(-1) { Connection::Connection(int fd) : socket_fd_(fd), local_port_(-1), remote_port_(-1), id_(0) { pthread_mutex_init(&c_mutex_, 0); pthread_mutex_init(&r_mutex_, 0); pthread_mutex_init(&w_mutex_, 0); if (socket_fd_ >= 0) if (socket_fd_ >= 0) { id_ = getconnid(); setallinfo_(); } } /** * Destructor Loading Loading @@ -352,6 +362,10 @@ int Connection::getremoteport() { return port; } unsigned long int Connection::getid() { return id_; } int Connection::getsocket() { pthread_mutex_lock(&c_mutex_); int ret = socket_fd_; Loading