getservent_r Subroutine

Purpose

Gets services file entry.

Library

Standard C Library (libc.a)

Syntax

#include <netdb.h>
int getservent_r(servent, serv_data)
struct servent *servent;
struct servent_data *serv_data;

Description

The getservent_r subroutine opens and reads the next line of the /etc/services file.An application program can use the getservent_r subroutine to retrieve information about network services and the protocol ports they use.

The /etc/services file remains open after a call by the getservent_r subroutine. To close the /etc/services file after each call, use the setservent_r subroutine. Otherwise, use the endservent_r subroutine to close the /etc/services file.

Parameters

Item Description
servent Points to the servent structure.
serv_data Points to the serv_data structure.

Return Values

The getservent_r fails when a successful match occurs. Thegetservent subroutine overwrites static data returned on subsequent calls. The getservent_r subroutine does not.

Files

Item Description
/etc/services Contains service names.