feat: checkerror output

This commit is contained in:
3lswear
2022-02-27 16:18:08 +03:00
parent 7f63fb2aae
commit f0154f99ab
2 changed files with 12 additions and 4 deletions

View File

@@ -17,6 +17,8 @@ Socket::Socket(int domain, int type, int protocol, int port, std::string ip)
min_config.ip = ip; min_config.ip = ip;
min_config.port = port; min_config.port = port;
this->port = port;
this->ip = ip;
} }
Socket::~Socket() Socket::~Socket()
@@ -83,7 +85,13 @@ int Socket::listeningSocket(int nbr)
int Socket::init(int nbr) int Socket::init(int nbr)
{ {
if (bindingSocket() < 0) if (bindingSocket() < 0)
return (-1); {
std::cerr << getDebugTime() << FAIL;
perror("Bind");
std::cerr << RESET;
return (-1);
}
if (listeningSocket(nbr) < 0) if (listeningSocket(nbr) < 0)
return (-1); return (-1);
return (0); return (0);
@@ -95,9 +103,7 @@ void Socket::checkError(int fd, std::string str)
{ {
if (fd < 0) if (fd < 0)
{ {
std::cout << RED << "Socket ERROR: " << str << ZERO_C << std::endl; perror(str.c_str());
exit(1); exit(1);
} }
else
std::cout << GREEN << "Socket SUCCESS: " << str << ZERO_C << std::endl;
} }

View File

@@ -28,6 +28,8 @@ public:
void checkError(int fd, std::string str); void checkError(int fd, std::string str);
struct serverListen min_config; struct serverListen min_config;
int port;
std::string ip;
~Socket(); ~Socket();
}; };