Added a function to get SO_ERROR on a socket.

This commit is contained in:
ANR2ME 2022-03-24 08:12:27 +07:00
parent 86315fed3d
commit d5152752d2
2 changed files with 14 additions and 0 deletions

View file

@ -1989,6 +1989,15 @@ int setSockTimeout(int sock, int opt, unsigned long timeout_usec) { // opt = SO_
return setsockopt(sock, SOL_SOCKET, opt, (char*)&optval, sizeof(optval));
}
int getSockError(int sock) {
int result = 0;
socklen_t result_len = sizeof(result);
if (getsockopt(sock, SOL_SOCKET, SO_ERROR, (char*)&result, &result_len) < 0) {
result = errno;
}
return result;
}
int getSockNoDelay(int tcpsock) {
int opt = 0;
socklen_t optlen = sizeof(opt);

View file

@ -1340,6 +1340,11 @@ int setSockMSS(int sock, int size);
*/
int setSockTimeout(int sock, int opt, unsigned long timeout_usec);
/*
* Get Socket SO_ERROR (Requests and clears pending error information on the socket)
*/
int getSockError(int sock);
/*
* Get TCP Socket TCP_NODELAY (Nagle Algo)
*/