Check if the clientSocket is a non-blocking socket

This commit is contained in:
2024-02-13 17:02:43 +01:00
parent 7eaf236bf5
commit e31d8b5949

View File

@@ -252,11 +252,13 @@ void ArucoDetector::setNonBlocking(int sockfd) {
int flags = fcntl(sockfd, F_GETFL, 0);
if (flags == -1) {
// Handle error
std::cout << "Error: Could not set socket to non-blocking." << std::endl;
perror("fcntl F_GETFL");
return;
}
if (fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) == -1) {
// Handle error
std::cout << "Error: Could not set socket to non-blocking." << std::endl;
perror("fcntl F_SETFL O_NONBLOCK");
return;
}