diff --git a/srcs/DccClient.cpp b/srcs/DccClient.cpp index ffa86e9..86d98d9 100644 --- a/srcs/DccClient.cpp +++ b/srcs/DccClient.cpp @@ -63,8 +63,13 @@ int DccClient::init() return (-1); } - int flags = fcntl(_sockfd, F_GETFL, 0); - fcntl(_sockfd, F_SETFL, flags | O_NONBLOCK); + if (fcntl(_sockfd, F_SETFL, O_NONBLOCK) < 0) + { + std::cerr << "Error: setting socket DCC Client non-blocking" << std::endl; + close(_sockfd); + _sockfd = -1; + return (-1); + } struct sockaddr_in serv_addr; memset(&serv_addr, 0, sizeof(serv_addr)); diff --git a/srcs/DccServer.cpp b/srcs/DccServer.cpp index 18c6294..1f54e36 100644 --- a/srcs/DccServer.cpp +++ b/srcs/DccServer.cpp @@ -42,8 +42,12 @@ int DccServer::init() } //config socket non-blocking - int flags = fcntl(_sockfd, F_GETFL, 0); - fcntl(_sockfd, F_SETFL, flags | O_NONBLOCK); + if (fcntl(_sockfd, F_SETFL, O_NONBLOCK) < 0) + { + std::cerr << "Error: setting socket DCC non-blocking" << std::endl; + close(_sockfd); + return (-1); + } //config address struct sockaddr_in addr;