diff --git a/src/Server/Server.cpp b/src/Server/Server.cpp index 8b37e17..1525068 100644 --- a/src/Server/Server.cpp +++ b/src/Server/Server.cpp @@ -11,14 +11,12 @@ Server::Server() { bzero(_events, sizeof(_events)); - _client = 0; } Server::Server(std::string path) { (void)path; - _client = 0; } void Server::print_epoll_events(unsigned int events) @@ -69,8 +67,8 @@ void Server::sendData(Client &client, int fd) else send_len = BUFFSIZE; - /* std::cout << YELLO << tmp << RESET << std::endl; */ - /* std::cout << GREEN << client.getCounter() << RESET << std::endl; */ + /* DBOUT << YELLO << tmp << ENDL; */ + /* DBOUT << GREEN << client.getCounter() << ENDL; */ if (send(fd, tmp + client.getCounter(), send_len, MSG_NOSIGNAL) < 0) @@ -89,7 +87,7 @@ void Server::readSocket(Client &client, int fd) int bytes_read; char buf[BUFFSIZE + 1]; - DBOUT << TURQ << "IN readSocket" << RESET << std::endl; + DBOUT << TURQ << "IN readSocket" << ENDL; DBOUT << "client in readSocket "<< &client << ENDL; bytes_read = recv(fd, buf, BUFFSIZE, 0); if (bytes_read == 0) @@ -108,13 +106,13 @@ void Server::readSocket(Client &client, int fd) client.allRead = true; } - std::cerr << "recvCounter " << client.getRecvCounter() << std::endl; - std::cerr << "contentLength " << client.getRequest().getContentLength() << std::endl; - std::cerr << "allRead " << client.allRead << std::endl; + DBOUT << GREEN << "recvCounter " << client.getRecvCounter() << ENDL; + DBOUT << GREEN << "contentLength " << client.getRequest().getContentLength() << ENDL; + DBOUT << GREEN << "allRead " << client.allRead << ENDL; - DBOUT << BLUE << "status is " << Response::getReasonPhrase(status) << RESET << std::endl; - bzero(buf, BUFFSIZE); + DBOUT << BLUE << "status is " << Response::getReasonPhrase(status) << ENDL; } + int Server::delete_client(std::map &client_map, int fd) { int ret; @@ -149,12 +147,11 @@ void Server::add_to_epoll_list(int fd, unsigned int ep_events) ev.data.fd = fd; assert(epoll_ctl(_epoll_fd, EPOLL_CTL_ADD, fd, &ev) == 0); - _client++; - std::cerr << YELLO + DBOUT << YELLO << "add socket " << fd << " to epoll_list" - << RESET << std::endl; + << ENDL; } void Server::start(void) @@ -178,7 +175,7 @@ void Server::start(void) { ready_num = epoll_wait(_epoll_fd, _events, MAX_CLIENT, -1); - /* std::cout << TURQ << "ready_num " << ready_num << RESET << std::endl; */ + /* DBOUT << TURQ << "ready_num " << ready_num << ENDL; */ if (ready_num < 0) throw std::logic_error("epoll_ret"); @@ -267,11 +264,11 @@ void Server::checkError(int fd, std::string str) { if (fd < 0) { - std::cout << RED << "Server ERROR: " << str << ZERO_C << std::endl; + DBOUT << RED << "Server ERROR: " << str << ENDL; exit(1); } else - std::cout << GREEN << "Server SUCCESS: " << str << ZERO_C << std::endl; + DBOUT << GREEN << "Server SUCCESS: " << str << ENDL; } Server::~Server() diff --git a/src/Server/Server.hpp b/src/Server/Server.hpp index 3a29ec6..429b39f 100644 --- a/src/Server/Server.hpp +++ b/src/Server/Server.hpp @@ -15,7 +15,6 @@ class Server private: int _port; int _epoll_fd; - int _client; struct epoll_event _events[MAX_CLIENT]; struct sockaddr_in _addres; std::string _ip;