[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Communications Technical Reference, Volume 2

setservent Subroutine


Opens /etc/services file and sets the file marker.


Standard C Library (libc.a)


#include <netdb.h>
void setservent (StayOpen)
int StayOpen;


Attention: Do not use the setservent subroutine in a multithreaded environment.

The setservent subroutine opens the /etc/services file and sets the file marker at the beginning of the file.


StayOpen Indicates when to close the /etc/services file.

Specifying a value of 0 closes the file after each call to the getservent subroutine.

Specifying a nonzero value allows the file to remain open after each call.

Return Values

If an error occurs or the end of the file is reached, the setservent subroutine returns a null pointer.

Implementation Specifics

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

All applications containing the setservent 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.


/etc/services Contains service names.

Related Information

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

Sockets Overview and Understanding Network Address Translation in AIX Version 4.3 Communications Programming Concepts.

[ Previous | Next | Contents | Glossary | Home | Search ]