Using the select Subroutine Example

This section explains using the select subroutine example.

The code for the svc_run routine with the select subroutine is as follows:

void
svc_run()
{
    fd_set readfds;
    int dtbsz = getdtablesize();

    for (;;) {
        readfds = svc_fds;
        switch (select(dtbsz, &readfds, NULL,NULL,NULL)) {

        case -1:
            if (errno == EINTR)
                continue;
            perror("select");
            return;
        case 0:
            break;
        default:
            svc_getreqset(&readfds);
        }
    }
}

The maximum number of open file descriptors that an RPC server can use has been set to 32767 in order to maintain compatability with RPC-server applications built on earlier releases of AIX®. The fd_set type passed into the svc_getreqset subroutine needs to have been compiled with FD_SETSIZE set to 32767 or larger. Passing in a smaller fd_set variable may result in the passed in buffer being overrun by the svc_getreqset subroutine.