Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions srcs/DccClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,8 @@ int DccClient::init()
return (-1);
}

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);
}
int flags = fcntl(_sockfd, F_GETFL, 0);
fcntl(_sockfd, F_SETFL, flags | O_NONBLOCK);

struct sockaddr_in serv_addr;
memset(&serv_addr, 0, sizeof(serv_addr));
Expand Down
11 changes: 2 additions & 9 deletions srcs/DccServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ int DccServer::init()
}

//config socket non-blocking
if (fcntl(_sockfd, F_SETFL, O_NONBLOCK) < 0)
{
std::cerr << "Error: setting socket DCC non-blocking" << std::endl;
close(_sockfd);
return (-1);
}
int flags = fcntl(_sockfd, F_GETFL, 0);
fcntl(_sockfd, F_SETFL, flags | O_NONBLOCK);

//config address
struct sockaddr_in addr;
Expand Down Expand Up @@ -139,6 +135,3 @@ bool DccServer::handleConnection()
std::cout << "File " << _filename << " sent successfully." << std::endl;
return false;
}