J'ai une simulation client - server - server socket
avec communication bidirectionnelle.Comment déboguer TCP recv()
Ma ligne
recv(fd3, serv3_buf, BUFSIZE - 1, 0);
retours -1
Comment pouvez-vous déboguer recv
en utilisant errno.h
?
J'ai une simulation client - server - server socket
avec communication bidirectionnelle.Comment déboguer TCP recv()
Ma ligne
recv(fd3, serv3_buf, BUFSIZE - 1, 0);
retours -1
Comment pouvez-vous déboguer recv
en utilisant errno.h
?
Voici l'explication de l'utilisateur (ual) des relevés d'erreur à recv!
ERREURS Voici quelques erreurs standard générées par la couche socket. Des erreurs supplémentaires peuvent être générées et renvoyées à partir des prototypes sous-jacents ; voir leurs pages de manuel.
EAGAIN or EWOULDBLOCK The socket is marked nonblocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received. POSIX.1-2001 allows either error to be returned for this case, and does not require these constants to have the same value, so a portable application should check for both possibilities. EBADF The argument sockfd is an invalid descriptor. ECONNREFUSED A remote host refused to allow the network connection (typically because it is not running the requested service). EFAULT The receive buffer pointer(s) point outside the process's address space. EINTR The receive was interrupted by delivery of a signal before any data were available; see signal(7). EINVAL Invalid argument passed. ENOMEM Could not allocate memory for recvmsg(). ENOTCONN The socket is associated with a connection-oriented protocol and has not been connected (see connect(2) and accept(2)). ENOTSOCK The argument sockfd does not refer to a socket.
Vous pouvez utiliser pour gérer une chaîne d'erreur perror() et strerror() lors du retour de recv -1.
Voir l'homme concerné (uel) pour l'explication:
Merci. J'avais vu cette information sur la recherche, mais je ne savais pas comment incorporer obtenir ces erreurs à afficher –
J'ai récupéré l'erreur avec perror 'Opération Socket sur non-socket'. Je vais enquêter plus loin. –
Bonne chance! Je suis content si je t'ai aidé! :) –
windows ou linux? – Christophe
utiliser perror ..... – pm100
'linux/Mac Terminal' en utilisant' gcc' –