change ip

This commit is contained in:
Talyx
2022-01-20 23:16:17 +03:00
parent 7c4ecd91e3
commit 131f9d1d11
4 changed files with 5 additions and 5 deletions

View File

@@ -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);

View File

@@ -6,7 +6,7 @@ Header::Header()
{
this->_row = 0;
this->_fd = -1;
this->_autoIndex = 0;
this->_autoIndex = 1;
initErrorCode();
}

View File

@@ -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;

View File

@@ -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);
}