feat: pass servers ip, port to client

This commit is contained in:
3lswear
2022-02-08 21:48:09 +03:00
parent 60a354d8a6
commit 0a791b2303
3 changed files with 17 additions and 8 deletions

View File

@@ -235,20 +235,23 @@ void Server::start(void)
int client_sock = accept(fd,
(sock_it->second).getSockaddr(), (sock_it->second).getSocklen());
if (client_sock > 0)
{
client_map[client_sock] = new Client((sock_it->second).min_config);
add_to_epoll_list(client_sock, client_events);
}
else
throw std::logic_error("accept didnt work");
}
else
{
if (client_map.find(fd) == client_map.end())
client_map[fd] = new Client();
/* if (client_map.find(fd) == client_map.end()) */
/* client_map[fd] = new Client(); */
if (events & EPOLLIN)
{
readSocket(*client_map[fd], fd);
if (client_map[fd]->readyToSend())
{
client_map[fd]->generateRespons();
client_map[fd]->generateRespons(_configs);
struct epoll_event ev;