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

getprotobyname Subroutine

Purpose

Gets protocol entry from the /etc/protocols file by protocol name.

Library

Standard C Library (libc.a)

Syntax

#include <netdb.h>
struct protoent *getprotobyname (Name)
char *Name;

Description

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

The getprotobyname subroutine retrieves protocol information from the /etc/protocols file by protocol name. An application program can use the getprotobyname subroutine to access a protocol name, its aliases, and protocol number.

The getprotobyname subroutine searches the protocols file sequentially from the start of the file until it finds a matching protocol name or until it reaches the end of the file. The subroutine returns a pointer to a protoent structure, which contains fields for a line of information in the /etc/protocols file. The netdb.h file defines the protoent structure.

Use the endprotoent subroutine to close the /etc/protocols file.

Parameters

Name Specifies the protocol name.

Return Values

Upon successful completion, the getprotobyname subroutine returns a pointer to a protoent structure.

Note: The return value points to static data that is overwritten by subsequent calls.

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

Implementation Specifics

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

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

Related Information

The endprotoent subroutine, getprotobynumber subroutine, getprotoent subroutine, setprotoent subroutine.

Sockets Overview in AIX Version 4.3 Communications Programming Concepts.


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