The file that is opened implicitly for getprotoent(3) can be rewound by calling the setprotoent(3) function. The function synopsis for it is as follows:
void setprotoent(int stayopen);
This function accepts one argument, stayopen, which is interpreted as a Boolean value:
- When stayopen is non-zero (TRUE), this indicates that the implicitly opened file is left opened and merely rewound to the start of the file.
- When stayopen is zero (FALSE), this indicates that the implicitly opened file is closed and then re-opened, effectively rewinding the file.
Best performance is obtained by setting stayopen as TRUE.