Previous | Contents | Index |
Returns the socket device channel (SDC) associated with a socket descriptor.
#include <socket.h>short int decc$get_sdc ( int s );
s
A socket descriptor.
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).
0 Indicates that s is not an open socket descriptor. x The SDC number.
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.
#include <netdb.h>struct hostent *gethostbyaddr ( const void *addr, size_t len, int type );
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.
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.
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.
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.
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.
#include <netdb.h>struct hostent *gethostbyname ( char *name );
name
A pointer to a null-terminated character string containing the name or an alias of the host being sought.
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.
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.
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.
Returns the fully qualified name of the local host.
#include <types.h>#include <socket.h>
int gethostname ( char *name, int namelen) ;
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.
This function returns the translation of the logical names TCPIP$INET_HOST and TCPIP$INET_DOMAIN when used with the TCP/IP Services software.
0 Successful completion. -1 Error; errno is set to indicate the error.
EFAULT The buffer described by name and namelen is not a valid, writable part of the user address space.
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.
#include <netdb.h>struct netent *getnetbyaddr ( long net, int type) ;
net
The network number, in host byte order, of the networks database entry required.type
The type of network being sought (AF_INET).
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.
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.
EINVAL The net argument is invalid. ESRCH The search failed.
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.
#include <netdb.h>struct netent *getnetbyname ( char *name );
name
A pointer to a null-terminated character string containing either the network name or an alias for the network name.
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.
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.
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.
Returns the name of the connected peer.The $QIO equivalent is the IO$_SENSEMODE function with the p4 argument.
#include <types.h>#include <socket.h>
int getpeername ( int s, struct sockaddr *name, int *namelen );
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.
This function returns the name of the peer connected to the specified socket descriptor.Related Functions
See also bind() , socket() , and getsockname() .
0 Successful completion. -1 Error; errno is set to indicate the error.
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.
Searches the protocols database until a matching protocol name is found or until end of file is encountered.
#include <netdb.h>struct protoent *getprotobyname ( char *name );
name
A pointer to a string containing the desired protocol name.
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() .
NULL Indicates end of file or an error; errno is set to one of the following values. x A pointer to a protoent structure.
Searches the protocols database until a matching protocol number is found or until end of file is encountered.
#include <netdb.h>struct protoent *getprotobynumber ( int *proto) ;
proto
A pointer to a string containing the desired protocol number.
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() .
NULL Indicates end of file or an error. x A pointer to a protoent structure.
Reads the next line from the protocols database.
#include <netdb.h>struct protoent *getprotoent();
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() .
NULL Indicates an end of file or an error. x A pointer to a protoent structure.
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 (TCP or UDP) for which to search.
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() .
NULL Indicates end of file 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 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.
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() .
NULL Indicates end of file or an error. x A pointer to a servent structure.
Previous | Next | Contents | Index |