mirror of
https://github.com/modelec/detection_pot.git
synced 2026-03-20 14:30:30 +01:00
Print serverSocket for debuging
This commit is contained in:
@@ -266,35 +266,22 @@ void ArucoDetector::setNonBlocking(int sockfd) {
|
||||
|
||||
void ArucoDetector::sendData(int serverSocket, const std::string& data) {
|
||||
std::cout << "Sending Data" << std::endl;
|
||||
|
||||
while (true) {
|
||||
int clientSocket = accept(serverSocket, nullptr, nullptr);
|
||||
if (clientSocket == -1) {
|
||||
if (errno == EWOULDBLOCK || errno == EAGAIN) {
|
||||
// Aucune connexion en attente, sortir de la boucle
|
||||
break;
|
||||
} else {
|
||||
// Erreur inattendue lors de l'acceptation de la connexion
|
||||
perror("accept");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Client Socket: " << clientSocket << std::endl;
|
||||
|
||||
std::cout << serverSocket << std::endl;
|
||||
int clientSocket = accept(serverSocket, nullptr, nullptr);
|
||||
std::cout << "Client Socket: " << clientSocket << std::endl;
|
||||
if(clientSocket == -1 && errno != EWOULDBLOCK && errno != EAGAIN) {
|
||||
perror("accept");
|
||||
return;
|
||||
}
|
||||
if(clientSocket != -1) {
|
||||
setNonBlocking(clientSocket);
|
||||
|
||||
// Vérifiez si le socket est réellement non bloquant
|
||||
if (fcntl(clientSocket, F_GETFL) & O_NONBLOCK) {
|
||||
if(fcntl(clientSocket, F_GETFL) & O_NONBLOCK) {
|
||||
std::cout << "Socket is non-blocking" << std::endl;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
std::cout << "Socket is still blocking" << std::endl;
|
||||
}
|
||||
|
||||
// Envoyer des données au client
|
||||
send(clientSocket, data.c_str(), data.size(), 0);
|
||||
|
||||
// Fermer le socket client
|
||||
close(clientSocket);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user