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

Technical Reference: Communications, Volume 2


getnetbyaddr Subroutine

Purpose

Gets network entry by address.

Library

Standard C Library (libc.a)

Syntax

#include <netdb.h>


struct netent *getnetbyaddr ( Network, Type)
long Network;
int Type;

Description

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

The getnetbyaddr subroutine retrieves information from the /etc/networks file using the network address as a search key. The getnetbyaddr subroutine searches the file sequentially from the start of the file until it encounters a matching net number and type or until it reaches the end of the file.

The getnetbyaddr subroutine returns a pointer to a netent structure, which contains the equivalent fields for a network description line in the /etc/networks file. The netent structure is defined in the netdb.h file.

Use the endnetent subroutine to close the /etc/networks file.

Parameters


Network Specifies the number of the network to be located.
Type Specifies the address family for the network. The only supported value is AF_INET.

Return Values

Upon successful completion, the getnetbyaddr subroutine returns a pointer to a netent 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 getnetbyaddr subroutine returns a null pointer.

Implementation Specifics

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

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

Files


/etc/networks
                          Contains official network names.

Related Information

The endnetent subroutine, getnetbyname subroutine, getnetent subroutine, setnetent subroutine.

Sockets Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.


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