Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ getservbyport(3) — OSF/1 SILVER Baselevel 4 rev36

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getprotobyname(3)

getprotobynumber(3)

getprotoent(3)

setprotoent(3)

endprotoent(3)

getservbyport(3)  —  Subroutines

OSF  —  Environment_Note_Added

NAME

getservbyport − Gets service entry by port

LIBRARY

Sockets Library (libc.a)

SYNOPSIS

#include <netdb.h>

struct servent ∗getservbyport (
int port,
char ∗proto );

PARAMETERS

portSpecifies the port number where the service is located. 

protoSpecifies the protocol name to use when contacting the service. 

DESCRIPTION

The getservbyport() function returns a pointer to a structure of
 
type servent. Its members specify data in fields from a record line in the /etc/services network services database file. The netdb.h header file defines the servent structure. 

The getservbyport() function searches the /etc/services file sequentially until a match with the port parameter or with the proto parameter occurs. When used, the proto parameter must specify the /etc/services file protocol name. When a port number is not used (port parameter is null), the port parameter need not be matched during the /etc/services file record search. When EOF (End-of-File) is reached without a match, an error value is returned by this function. 

The getservbyport() function searches the /etc/services file sequentially until one of the following occurs:

       •A port number and protocol name match. 

       •A protocol name match when the port parameter is set to null. 

       •The end of the file is reached. 

Use the endservent() function to close the /etc/services file. 

NOTES

The return value points to static data, which is overwritten by any subsequently called functions using the same structure. 

RETURN VALUES

Upon successful completion, a pointer to a servent structure is returned.  A null pointer is returned when an error occurs or whenever the end of the /etc/services file is reached. 

FILES

/etc/services
The DARPA Internet network service-name database. Each record in the file occupies a single line and has four fields consisting of the official service name, port number, protocol name, and aliases.

ENVIRONMENT NOTES

This section describes system features that are not generic to OSF/1 but that are provided in this OSF/1 implementation. 

Digital Extensions

The system searches either the local /etc/services file or the NIS distributed networks file for the requested information.  To determine which file or files to search, and in which order, the system uses the switches in the /etc/svc.conf file. 
 

RELATED INFORMATION

Functions: getprotobyname(3), getprotobynumber(3), getprotoent(3), setprotoent(3), endprotoent(3)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026