From 131f9d1d112a95decafea0e0730a494119605a4b Mon Sep 17 00:00:00 2001 From: Talyx Date: Thu, 20 Jan 2022 23:16:17 +0300 Subject: [PATCH] change ip --- includes/Socket.hpp | 2 +- src/Header.cpp | 2 +- src/Server.cpp | 2 +- src/Socket.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/Socket.hpp b/includes/Socket.hpp index ea43dc7..7fd4187 100644 --- a/includes/Socket.hpp +++ b/includes/Socket.hpp @@ -12,7 +12,7 @@ private: public: Socket(); - Socket(int domain, int type, int protocol, int port); + Socket(int domain, int type, int protocol, int port, std::string ip); int getSocketFd(void); struct sockaddr_in getAddres(void); socklen_t getAddlen(void); diff --git a/src/Header.cpp b/src/Header.cpp index a8ea807..8322e4a 100644 --- a/src/Header.cpp +++ b/src/Header.cpp @@ -6,7 +6,7 @@ Header::Header() { this->_row = 0; this->_fd = -1; - this->_autoIndex = 0; + this->_autoIndex = 1; initErrorCode(); } diff --git a/src/Server.cpp b/src/Server.cpp index 06bb1c6..1b35312 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -44,7 +44,7 @@ void Server::newConnection(int fd) void Server::start(void) { - Socket serverSocket(AF_INET, SOCK_STREAM, 0, _port); + Socket serverSocket(AF_INET, SOCK_STREAM, 0, _port, "127.0.0.1"); char buff[BUFFSIZE + 1] = {0}; Header header; int fd_accept; diff --git a/src/Socket.cpp b/src/Socket.cpp index 2008d4d..ab6a99b 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -4,7 +4,7 @@ Socket::Socket() { } -Socket::Socket(int domain, int type, int protocol, int port) +Socket::Socket(int domain, int type, int protocol, int port, std::string ip) { int opt = 1; _socketFd = socket(domain, type, protocol); @@ -13,7 +13,7 @@ Socket::Socket(int domain, int type, int protocol, int port) | SO_REUSEPORT, &opt, sizeof(opt)), "Set socket options"); _addres.sin_family = domain; _addres.sin_port = htons(port); - _addres.sin_addr.s_addr = INADDR_ANY; + _addres.sin_addr.s_addr = inet_addr(ip.c_str()); _addrlen = sizeof(_addres); }