[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Communications, Volume 2

endservent Subroutine


Closes the /etc/services file.


Standard C Library (libc.a)


#include <netdb.h>

void endservent ( )


The endservent subroutine closes the /etc/services file. A call made to the getservent subroutine, getservbyname subroutine, or getservbyport subroutine opens the /etc/services file. An application program can use the endservent subroutine to close the /etc/services file.

Return Values

If a previous setservent subroutine has been performed and the StayOpen parameter does not equal 0, then the endservent subroutine will not close the /etc/services file. Also, the setservent subroutine does not indicate that it closed the file. A second setservent subroutine has to be issued with the StayOpen parameter equal to 0 in order for a following endservent subroutine to succeed. If this is not done, the /etc/services file closes on an exit subroutine.


To close the /etc/services file:

endservent ();

Implementation Specifics

The endservent subroutine is part of Base Operating System (BOS) Runtime.

All applications containing the endservent subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.


                          Contains service names.

Related Information

The endprotoent subroutine, exit subroutine, getprotobyname subroutine, getprotobynumber subroutine, getprotoent subroutine, getservbyname subroutine, getservbyport subroutine, getservent subroutine, setprotoent subroutine, setservent subroutine.

Sockets Overview, Understanding Network Address Translation, and List of Socket Programming References in AIX 5L Version 5.1 Communications Programming Concepts.

[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]