United States |
Previous | Contents | Index |
Closes the network services database file.
#include <netdb.h>void endservent (void);
The endservent routine closes the network services database file, previously opened with the getservent , getservbyname , or getservbyport routine.See also getservent , getservbyname , and getservbyport in this section.
If the endservent routine does not exist in your TCP/IP library, then errno is set to ENOSYS.
Returns the standard host address for the processor.
#include <socket.h>int gethostaddr (char *addr);
addr
A pointer to the buffer in which the standard host address for the current processor is returned.
This system call returns the standard host address for the current processor. The returned address is null-terminated. The addr parameter must point to at least 16 bytes of free space.Host addresses are limited to 16 characters.
0 Indicates success. --1 Indicates that an error has occurred and is further specified in the global errno .
Searches the host database sequentially from the beginning of the database for a host record with a given address.
#include <netdb.h>Routine Variants This socket routine has a variant named __bsd44_gethostbyaddr . Enabled by defining _sockaddr_len , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.struct hostent *gethostbyaddr (char *addr, int len, int type);
addr
A pointer to a series of bytes in network order specifying the address of the host sought. This argument does not point to an ASCII string.len
The number of bytes in the address pointed to by the addr argument.type
The type of address format being sought. Currently, only AF_INET (defined in <socket.h> ) is supported.)
This routine finds the first host record in the host database with the given address.The gethostbyaddr routine uses a common static area for its return values. This means that subsequent calls this routine will overwrite any existing host entry. You must make a copy of the host entry if you wish to save it.
NULL Indicates an error. x A pointer to an object having the hostent structure. See <netdb.h> for a description of the hostent structure. Depending on the error condition and the socket implementation selected, errno or h_errno might be set to further indicate the error. (See sections A.5 and A.6.)
Searches the host database sequentially from the beginning of the database for a host record with a given name or alias.
#include <netdb.h>Routine Variants This socket routine has a variant named __bsd44_gethostbyname . Enabled by defining _sockaddr_len , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.struct hostent *gethostbyname (char *name);
name
A pointer to a null-terminated character string containing the name or an alias of the host sought.
This routine finds the first host in the host database with the given name or alias.The gethostbyname routine uses a common static area for its return values. This means that subsequent calls to this routine will overwrite any existing host entry. You must make a copy of the host entry if you wish to save it.
NULL Indicates an error. x A pointer to an object having the hostent structure. See <netdb.h> for a description of the hostent structure. Depending on the error condition and the socket implementation selected, errno or h_errno might be set to further indicate the error. (See sections A.5 and A.6.)
Gets a host file entry from the network host database file.
#include <netdb.h>struct hostent *gethostent (void);
The gethostent routine reads the next entry of the database, opening a connection to the database, if necessary.See the <netdb.h> header file for a description of the hostent structure.
This routine uses a common static area for its return values. Therefore, subsequent calls to this routine overwrite any existing network entry. You must make a copy of the network services entry, if you wish to save it.
x A pointer to the hostent structure. NULL Indicates an error.
Returns the name currently associated to the host.
#include <socket.h>int gethostname (char *name, int namelen);
(_DECC_V4_SOURCE) int gethostname (char *name, size_t namelen);
(NOT _DECC_V4_SOURCE)
name
The address of a buffer into which the name should be written. The returned name is null-terminated unless sufficient space is not provided.namelen
The size of the buffer pointed to by name.
This routine returns the hostname maintained by the TCP/IP Services for OpenVMS or compatible TCP/IP product.
0 Indicates success. --1 Indicates an error; errno is set to one of the following:
- EFAULT -- The buffer decribed by name and namelen is not a valid, writable part of the user address space.
- EINVAL -- The returned name is an invalid address.
Searches the network database sequentially from the beginning of the database for a network record with a given address.
#include <netdb.h>struct netent *getnetbyaddr (long net, int type);
net
The network number, in host byte order, of the network database entry required.type
The type of network sought. Currently, only AF_INET (defined in <socket.h> ) is supported.)
This routine finds the first network record in the network database with the given address.The getnetent , getnetbyaddr , and getnetbyname routines all use a common static area for their return values. This means that subsequent calls to any of these routines will overwrite any existing network entry. You must make a copy of the network entry if you wish to save it.
NULL Indicates EOF or an error. x A pointer to an object having the netent structure. See the <netdb.h> header file for a description of the netent structure.
Searches the network database sequentially from the beginning of the database for a network record with a given name or alias.
#include <netdb.h>struct netent *getnetbyname (char *name);
name
A pointer to a null-terminated character string of the name or an alias of the network sought.
This routine finds the first host in the network database with the given name or alias.The getnetent , getnetbyaddr , and getnetbyname routines all use a common static area for their return values. This means that subsequent calls to any of these routines will overwrite any existing network entry. You must make a copy of the network entry if you wish to save it.
NULL Indicates EOF or an error; errno is set to EFAULT (The buffer described by name is not a valid, writable part of the user address space.) x A pointer to an object having the netent structure. See the <netdb.h> header file for a description of the netent structure. Depending on the error condition and the socket implementation selected, errno or h_errno might be set to further indicate the error. (See sections A.5 and A.6.)
Gets a network file entry from the networks database file.
#include <netdb.h>struct netent *getnetnet (void);
The getnetent routine opens and sequentially reads the networks database file to retrieve network information.See the <netdb.h> header file for a description of the netent structure.
The getnetent routine uses a common static area for its return values, so subsequent calls to this routine overwrite any existing network entry. You must make a copy of the network services entry, if you wish to save it.
See also setnetent , and endnetent in this section.
x A pointer to a netent structure. 0 Indicates an error or EOF.
Returns the name of the connected peer.
#include <socket.h>Routine Variants This socket routine has a variant named __bsd44_getpeername . Enabled by defining _sockaddr_len , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.int getpeername (int s, struct sockaddr *name, int *namelen);
(_DECC_V4_SOURCE) int getpeername (int s, struct sockaddr *name, size_t *namelen);
(NOT _DECC_V4_SOURCE)
s
A socket descriptor that has been created using socket .name
A pointer to a buffer within which the peer name is to be returned.namelen
An address of an integer that specifies the size of the name buffer. On return, it will be modified to reflect the actual length, in bytes, of the name returned.
This routine returns the name of the peer connected to the socket descriptor specified.See also bind , getsockname , and socket in this appendix.
0 Indicates success. --1 Indicates an error; errno is set to one of the following:
- EBADF -- The descriptor is invalid.
- ENOTSOCK -- The socket descriptor references a file, not a socket.
- ENOTCONN -- The socket is not connected.
- ENOBUFS -- Resources were insufficient in the system to perform the operation.
- EFAULT -- The name parameter is not a valid part of the user address space.
Searches the protocols database until a matching protocol name is found or until EOF is encountered.
#include <netdb.h>struct protoent *getprotobyname (char *name);
name
A pointer to a string containing the desired protocol name.
This routine returns a pointer to a protoent structure containing the broken-out fields of the requested line from the protocols database.See the <netdb.h> header file for a description of the protoent structure.
See also getprotoent and getprotobynumber in this section.
NULL Indicates EOF or an error. x A pointer to a protoent structure.
Searches the protocols database until a matching protocol number is found or until an EOF is encountered.
#include <netdb.h>struct protoent *getprotobynumber (int *proto);
proto
A pointer to a string containing the desired protocol number.
This routine returns a pointer to a protoent structure containing the broken-out fields of the requested line from the protocols database.See the <netdb.h> header file for a description of the protoent structure.
See also getprotoent and getprotobyname in this section.
NULL Indicates EOF or an error. x A pointer to a protoent structure.
Gets a protocol database entry from the protocols database file.
#include <netdb.h>struct protoent *getprotoent (void);
The getprotoent routine reads the next entry of the database, opening a connection to the database, if necessary.See the <netdb.h> header file for a description of the protoent structure.
See also getprotobyname , getprotobynumber , setprotoent , and endprotoent in this section.
x A pointer to a protoent structure. NULL Indicates an error or EOF.
Gets information on the named service from the network services database.
#include <netdb.h>struct servent *getservbyname (char *name, char *proto);
name
A pointer to a string containing the name of the service about which information is required.proto
A pointer to a string containing the name of the protocol to search for.
This routine searches sequentially from the beginning of the file until a matching service name is found, or until an EOF is encountered. If a protocol name is also supplied (non-NULL), searches must also match the protocol.This routine returns a pointer to a servent structure containing the broken-out fields of the requested line in the network services database.
See the <netdb.h> header file for a description of the servent structure.
All information is contained in a static area, so it must be copied if it is to be saved.
See also getservbyport in this section.
NULL Indicates EOF or an error. x A pointer to a servent structure.
Gets information on the specified port from the network services database.
#include <netdb.h>struct servent *getservbyport (int port, char *proto);
port
The port number to search for.proto
A pointer to a string containing the name of the protocol to search for.
This routine searches sequentially from the beginning of the file until a matching port is found, or until an EOF is encountered. If a protocol name is also supplied (non-NULL), searches must also match the protocol.This routine returns a pointer to a servent structure containing the broken-out fields of the requested line in the network services database. See the <netdb.h> header file for a description of the servent structure.
All information is contained in a static area, so it must be copied if it is to be saved.
See also getservbyname in this section.
NULL Indicates EOF or an error. x A pointer to a servent structure.
Gets a services file entry from the network services database file.
#include <netdb.h>struct servent *getservent (void);
The getservent routine reads the next line of the network services database file, opening a connection to the database, if necessary.This routine returns a servent structure that contains fields for a line of information from the network services database file. See the <netdb.h> header file for a description of the hostent structure.
This routine uses a common static area for its return values, so subsequent calls to this routine overwrite any existing network entry. You must make a copy of the network services entry, if you wish to save it.
See also setservent , and endservent in this section.
x A pointer to a servent structure. NULL Indicates an error or EOF.
Previous | Next | Contents | Index |
|