Compaq TCP/IP Services for OpenVMS
Sockets API and System Services Programming


Previous Contents Index


decc$get_sdc()

Returns the socket device channel (SDC) associated with a socket descriptor.

Format

#include <socket.h>

short int decc$get_sdc ( int s );


Argument

s

A socket descriptor.

Description

This function returns the SDC associated with a socket. Normally, socket descriptors are used either as file descriptors or with one of the functions that takes an explicit socket descriptor as its argument. Sockets are implemented using TCP/IP socket device channels. This function returns the SDC used by a given socket descriptor so you can use the TCP/IP facilities directly by means of various I/O system services ($QIO).

Return Values

0 Indicates that s is not an open socket descriptor.
x The SDC number.

gethostbyaddr()

Searches the hosts database sequentially from the beginning for a host record with a given IPv4 address.

The $QIO equivalent is the IO$_ACPCONTROL function with the INETACP_FUNC$C_GETHOSTBYADDR subfunction code.


Format

#include <netdb.h>

struct hostent *gethostbyaddr ( const void *addr, size_t len, int type );


Arguments

addr

A pointer to a series of bytes in network order specifying the address of the host sought.

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 is supported.

Description

This function finds the first host record in the hosts database with the given address.

The gethostbyaddr() function uses a common static area for its return values. This means that subsequent calls to this function overwrite previously returned host entries. You must make a copy of the host entry if you want to save it.


Return Values

NULL Indicates an error; errno is set to one of the following values.
x A pointer to an object having the hostent structure. See Section 3.2.1 for a description of the hostent structure.

Errors

ENETDOWN TCP/IP Services was not started.
HOST_NOT_FOUND Host is unknown.
NO_DATA The server recognized the request and the name, but no address is available for the name. Another type of name server request may be successful.
NO_RECOVERY An unexpected server failure occurred. This is a nonrecoverable error.
TRY_AGAIN A transient error occurred, for example, the server did not respond. A retry may be successful.

gethostbyname()

Searches the hosts database sequentially from the beginning for a host record with a given name or alias.

This function also invokes the BIND resolver to query the appropriate name server if the information requested is not in the hosts database.

The $QIO equivalent is the IO$_ACPCONTROL function with the INETACP_FUNC$C_GETHOSTBYNAME subfunction code.


Format

#include <netdb.h>

struct hostent *gethostbyname ( char *name );


Argument

name

A pointer to a null-terminated character string containing the name or an alias of the host being sought.

Description

This function finds the first host in the hosts database with the given name or alias.

The gethostbyname() function uses a common static area for its return values. This means that subsequent calls to this function overwrite previously returned host entries. You must make a copy of the host entry if you want to save it.


Return Values

NULL Indicates an error.
x A pointer to an object having the hostent structure. See Section 3.2.1 for a description of the hostent structure.

Errors

ENETDOWN TCP/IP Services was not started.
HOST_NOT_FOUND Host is unknown.
NO_DATA The server recognized the request and the name, but no address is available for the name. Another type of name server request may be successful.
NO_RECOVERY An unexpected server failure occurred. This is a nonrecoverable error.
TRY_AGAIN A transient error occurred, for example, the server did not respond. A retry may be successful.

gethostname()

Returns the fully qualified name of the local host.

Format

#include <types.h>

#include <socket.h>

int gethostname ( char *name, int namelen) ;


Arguments

name

The address of a buffer where the name should be returned. The returned name is null terminated unless sufficient space is not provided.

namelen

The size of the buffer pointed to by name.

Description

This function returns the translation of the logical names TCPIP$INET_HOST and TCPIP$INET_DOMAIN when used with the TCP/IP Services software.

Return Values

0 Successful completion.
-1 Error; errno is set to indicate the error.

Errors

EFAULT The buffer described by name and namelen is not a valid, writable part of the user address space.

getnetbyaddr()

Searches the network database sequentially from the beginning for a network record with a given address.

The $QIO equivalent is the IO$_ACPCONTROL function with the INETACP_FUNC$C_GETNETBYADDR subfunction code.


Format

#include <netdb.h>

struct netent *getnetbyaddr ( long net, int type) ;


Arguments

net

The network number, in host byte order, of the networks database entry required.

type

The type of network being sought (AF_INET).

Description

This function finds the first network record in the networks database with the given address.

The getnetbyaddr() and getnetbyname() functions use a common static area for their return values. Subsequent calls to any of these functions overwrite any previously returned network entry. You must make a copy of the network entry if you want to save it.


Return Values

NULL Indicates end of file or an error.
x A pointer to an object having the netent structure. See Section 3.2.6 for a description of the netent structure.

Errors

EINVAL The net argument is invalid.
ESRCH The search failed.

getnetbyname()

Searches the networks database sequentially from the beginning for a network record with a given name or alias.

The $QIO equivalent is the IO$_ACPCONTROL function with the INETACP_FUNC$C_GETNETBYNAME subfunction code.


Format

#include <netdb.h>

struct netent *getnetbyname ( char *name );


Argument

name

A pointer to a null-terminated character string containing either the network name or an alias for the network name.

Description

This function finds the first network record in the networks database with the given name or alias.

The getnetbyaddr() and getnetbyname() functions use a common static area for their return values. Subsequent calls to any of these functions overwrite previously returned network entries. You must make a copy of the network entry if you want to save it.


Return Values

NULL Indicates end of file or an error.
x A pointer to an object having the netent structure. See Section 3.2.6 for a description of the netent structure.

Errors

EFAULT The buffer described by name is not a valid, writable part of the user address space.
EINVAL The net or net_data argument is invalid.
ESRCH The search failed.

getpeername()

Returns the name of the connected peer.

The $QIO equivalent is the IO$_SENSEMODE function with the p4 argument.


Format

#include <types.h>

#include <socket.h>

int getpeername ( int s, struct sockaddr *name, int *namelen );


Arguments

s

A socket descriptor created using socket() .

name

A pointer to a buffer where the peer name is to be returned.

namelen

An address of an integer that specifies the size of the name buffer. On return, it is modified to reflect the actual length, in bytes, of the name returned.

Description

This function returns the name of the peer connected to the specified socket descriptor.

Related Functions

See also bind() , socket() , and getsockname() .


Return Values

0 Successful completion.
-1 Error; errno is set to indicate the error.

Errors

EBADF The descriptor is invalid.
EFAULT The name argument is not a valid part of the user address space.
EINVAL The socket has been shut down.
ENOBUFS The system has insufficient resources to complete the call.
ENOTCONN The socket is not connected.
ENOTSOCK The socket descriptor is invalid.
EOPNOTSUPP The operation is not supported for the socket protocol.

getprotobyname()

Searches the protocols database until a matching protocol name is found or until end of file is encountered.

Format

#include <netdb.h>

struct protoent *getprotobyname ( char *name );


Argument

name

A pointer to a string containing the desired protocol name.

Description

This function returns a pointer to a protoent structure containing data from the protocols database:


struct  protoent { 
        char   *p_name;       /* official name of protocol */ 
        char   **p_aliases;   /* alias list */ 
        long   p_proto;       /* protocol number */ 
}; 

The members of this structure are:
p_name The official name of the protocol.
p_aliases A zero-terminated list of alternate names for the protocol.
p_proto The protocol number.

All information is contained in a static area, so it must be copied to be saved.

Related Functions

See also getprotoent() and getprotobynumber() .


Return Values

NULL Indicates end of file or an error; errno is set to one of the following values.
x A pointer to a protoent structure.

getprotobynumber()

Searches the protocols database until a matching protocol number is found or until end of file is encountered.

Format

#include <netdb.h>

struct protoent *getprotobynumber ( int *proto) ;


Argument

proto

A pointer to a string containing the desired protocol number.

Description

This function returns a pointer to a protoent structure containing the data from the protocols database:


struct  protoent { 
        char   *p_name;       /* official name of protocol */ 
        char   **p_aliases;   /* alias list */ 
        long   p_proto;       /* protocol number */ 
}; 

The members of this structure are:
p_name The official name of the protocol.
p_aliases A zero-terminated list of alternate names for the protocol.
p_proto The protocol number.

All information is contained in a static area, so it must be copied to be saved.

Related Functions

See also getprotoent() and getprotobyname() .


Return Values

NULL Indicates end of file or an error.
x A pointer to a protoent structure.

getprotoent()

Reads the next line from the protocols database.

Format

#include <netdb.h>

struct protoent *getprotoent();


Description

This function returns a pointer to a protoent structure containing the data from the protocols database:


struct  protoent { 
        char   *p_name;       /* official name of protocol */ 
        char   **p_aliases;   /* alias list */ 
        long   p_proto;       /* protocol number */ 
}; 

The members of this structure are:
p_name The official name of the protocol.
p_aliases A zero-terminated list of alternate names for the protocol.
p_proto The protocol number.

The getprotoent() function keeps a pointer in the database, allowing successive calls to be used to search the entire file.

All information is contained in a static area, so it must be copied to be saved.

Related Functions

See also getprotobyname() and getprotobynumber() .


Return Values

NULL Indicates an end of file or an error.
x A pointer to a protoent structure.

getservbyname()

Gets information on the named service from the network services database.

Format

#include <netdb.h>

struct servent *getservbyname ( char *name, char *proto );


Arguments

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 (TCP or UDP) for which to search.

Description

This function searches sequentially from the beginning of the file until a matching service name is found, or until end of file is encountered. If a protocol name is also supplied, searches must also match the protocol.

This function returns a pointer to a servent structure containing the data from the network services database:


struct  servent { 
        char    *s_name;        /* official name of service */ 
        char    **s_aliases;    /* alias list */ 
        long    s_port;         /* port service resides at */ 
        char    *s_proto;       /* protocol to use */ 
}; 

The members of this structure are:
s_name The official name of the service.
s_aliases A zero-terminated list of alternate names for the service.
s_port The port number at which the service resides. Port numbers are returned in network byte order.
s_proto The name of the protocol to use when contacting the service.

All information is contained in a static area, so it must be copied to be saved.

Related Functions

See also getservbyport() .


Return Values

NULL Indicates end of file or an error.
x A pointer to a servent structure.

getservbyport()

Gets information on the specified port from the network services database.

Format

#include <netdb.h>

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


Arguments

port

The port number for which to search. This port number should be specified in network byte order.

proto

A pointer to a string containing the name of the protocol (TCP or UDP) for which to search.

Description

This function searches sequentially from the beginning of the file until a matching port is found, or until end of file is encountered. If a protocol name is also supplied, searches must also match the protocol.

This function returns a pointer to a servent structure containing the broken-out fields of the requested line in the network services database:


struct  servent { 
        char    *s_name;        /* official name of service */ 
        char    **s_aliases;    /* alias list */ 
        long    s_port;         /* port service resides at */ 
        char    *s_proto;       /* protocol to use */ 
}; 

The members of this structure are:
s_name The official name of the service.
s_aliases A zero-terminated list of alternate names for the service.
s_port The port number at which the service resides. Port numbers are returned in network byte order.
s_proto The name of the protocol to use when contacting the service.

All information is contained in a static area, so it must be copied to be saved.

Related Functions

See also getservbyname() .


Return Values

NULL Indicates end of file or an error.
x A pointer to a servent structure.


Previous Next Contents Index