/* Returns the size of socket 'sock''s receive buffer (SO_RCVBUF), or a * negative errno value if an error occurs. */ int get_socket_rcvbuf(int sock) { int rcvbuf; int error; error = getsockopt_int(sock, SOL_SOCKET, SO_RCVBUF, "SO_RCVBUF", &rcvbuf); return error ? -error : rcvbuf; }
/* Returns the error condition associated with socket 'fd' and resets the * socket's error status. */ int get_socket_error(int fd) { int error; if (getsockopt_int(fd, SOL_SOCKET, SO_ERROR, "SO_ERROR", &error)) { error = errno; } return error; }