DIGITAL TCP/IP Services for OpenVMS
System Services and C Socket Programming


Previous Contents Index


getsockname()

Returns the name associated with a socket.

The $QIO equivalent is the IO$_SENSEMODE or IO$_SENSECHAR function with the p3 argument.


Format

#include <types.h>

#include <socket.h>

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


Arguments

s

A socket descriptor created with socket() routine and bound to the socket name with bind() routine.

name

A pointer to the buffer in which getsockname() should return the socket name.

namelen

A pointer to an integer containing the size of the buffer pointed to by name. On return, the integer contains the actual size of the name returned, in bytes.

Description

This routine returns the current name for the specified socket descriptor. The name is a format specific to the address family (AF_INET) assigned to the socket.

The bind() routine makes the association of the name to the socket, not the getsockname() routine.

See also bind() and socket().


Return Values

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

Errors

[EBADF] The descriptor is invalid.
[ENOTSOCK] The socket descriptor references a file, not a socket.
[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.

getsockopt()

Returns the options set on a socket.

The $QIO equivalent is the IO$_SENSEMODE or IO$_SENSECHAR function.


Format

#include <types.h>

#include <socket.h>

int getsockopt (int s, int level, int optname, char *optval, int *optlen);


Arguments

s

A socket descriptor created by socket().

level

The protocol level for which the socket options are desired. It can have one of the following values:
SOL_SOCKET Get the options at the socket level.
p Any protocol number. Get the options for protocol level p. See the <in.h> file for the various IPPROTO values.

optname

Interpreted by the protocol specified in the level. Options at each protocol level are documented with the protocol.

For descriptions of the supported socket level options, see setsockopt() in this chapter.

optval

Points to a buffer in which the value of the specified option should be placed by getsockopt().

optlen

Points to an integer containing the size of the buffer pointed to by optval. On return, the integer is modified to contain the actual size of the option value returned.

Description

This routine gets information on socket options. See the appropriate protocol for information on available options at each protocol level.

Return Values

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

Errors

[EBADF] The descriptor is invalid.
[ENOTSOCK] The socket descriptor references a file, not a socket.
[ENOPROTOOPT] The option is unknown or the protocol is unsupported.

htonl()

Converts longwords from host to network byte order.

Format

#include <in.h>

unsigned long int htonl (unsigned long int hostlong);


Argument

hostlong

A longword in host byte order (OpenVMS systems). All integers on OpenVMS systems are in host byte order unless otherwise specified.

Description

This routine converts 32-bit unsigned integers from host byte order to network byte order.

The network byte order is the format in which data bytes are expected to be transmitted through a network. All hosts on a network should send data in network byte order. Not all hosts have an internal data representation format that is identical to the network byte order. The host byte order is the format in which bytes are ordered internally on a specific host. The host byte order on OpenVMS systems differs from the network order.

This routine is most often used with internet addresses. Network byte order places the byte with the most significant bits at lower addresses, whereas the OpenVMS system places the most significant bits at the highest address.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Value

x A longword in network byte order.

htons()

Converts short integers from host to network byte order.

Format

#include <in.h>

unsigned short int htons (unsigned short int hostshort);


Argument

hostshort

A short integer in host byte order (OpenVMS system). All short integers on the OpenVMS system are in host byte order unless otherwise specified.

Description

This routine converts 16-bit unsigned integers from host byte order to network byte order.

The network byte order is the format in which data bytes are expected to be transmitted through a network. All hosts on a network should send data in network byte order. Not all hosts have an internal data representation format that is identical to the network byte order. The host byte order is the format in which bytes are ordered internally on a specific host. The host byte order on OpenVMS systems differs from the network order.

This routine is most often used with ports as returned by getservent(). Network byte order places the byte with the most significant bits at lower addresses, whereas the OpenVMS system places the most significant bits at the highest address.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Value

x A short integer in network byte order. Integers in network byte order cannot be used for arithmetic computation on the OpenVMS system.

inet_addr()

Converts internet addresses in text form into numeric (binary) internet addresses in dotted decimal format.

Format

#include <in.h>

#include <inet.h>

int inet_addr (char *cp);


Argument

cp

A pointer to a null-terminated character string containing an internet address in the standard internet dotted decimal format.

Description

This routine returns an internet address in network byte order when given as its argument an ASCII (null-terminated) string representing the address in the internet standard "." notation.

Internet addresses specified with the "." notation take one of the following forms:


a.b.c.d 
a.b.c 
a.b 
a 

When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the 4 bytes of an internet address. Note that when an internet address is viewed as a 32-bit integer quantity on the OpenVMS system, the bytes appear in binary as "d.c.b.a". That is, OpenVMS bytes are ordered from least significant to most significant.

When only one part is given, the value is stored directly in the network address without any byte rearrangement.

All numbers supplied as "parts" in a "." address expression can be decimal, octal, or hexadecimal, as specified in the C language (that is, a leading 0x or 0X implies hexadecimal; a leading 0 implies octal; otherwise, the number is interpreted as decimal).

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Values

--1 Indicates that cp does not point to a proper internet address.
x An internet address in network byte order.

inet_lnaof()

Returns the local network address portion of an internet address.

Format

#include <in.h>

#include <inet.h>

int inet_lnaof (struct in_addr in);


Argument

in

An internet address.

Description

This routine returns the local network address portion of a full internet address.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Value

x The local network address portion of an internet address in host byte order.

inet_makeaddr()

Returns an internet address given a network address and a local address on that network.

Format

#include <in.h>

#include <inet.h>

struct in_addr inet_makeaddr (int net, int lna);


Arguments

net

An internet network address in host byte order.

lna

A local network address on network net in host byte order.

Description

This routine combines the net and lna arguments into a single internet address.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Value

x An internet address in network byte order.

inet_netof()

Returns the internet network address portion of an internet address.

Format

#include <in.h>

#include <inet.h>

int inet_netof (struct in_addr in);


Argument

in

An internet address.

Description

This routine returns the internet network address (NET) portion of a full internet address.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Value

x The internet network portion of an internet address in host byte order.

inet_network()

Converts a null-terminated text string representing an internet address into a network address in local host format.

Format

#include <in.h>

#include <inet.h>

int inet_network (char *cp);


Argument

cp

A pointer to an ASCII (null-terminated) character string containing a network address in the standard internet "." format.

Description

This routine returns an internet network address as local host integer values when given as its argument an ASCII string representing the address in the internet standard "." notation.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Values

--1 Indicates that cp does not point to a proper internet network address.
x An internet network address as local host integer values.

inet_ntoa()

Converts an internet address into a text string representing the address in the standard internet "." notation.

Format

#include <in.h>

#include <inet.h>

char *inet_ntoa (struct in_addr in);


Argument

in

An internet address in network byte order.

Description

This routine converts an internet address into an ASCII (null-terminated) string representing that address in the standard internet "." notation.

Warning

Arguments should not be passed as integers because of how DEC C handles struct arguments.

Because the string is returned in a static buffer that is overwritten by subsequent calls to inet_ntoa(), Compaq recommends copying the string to a safe place.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Value

x A pointer to a string containing the internet address in "." notation.

ioctl()

Controls devices. Used to set sockets for nonblocking I/O.

Format

#include <ioctl.h>

int ioctl (int fildes, int request, ... /* arg */);


Argument

fildes

Specifies the file descriptor of the requested device.

request

Specifies the type of ioctl command to be performed on the device. The request types are grouped as follows:

For a list of request types and their associated data types, see the <ioctl.h> header file.

arg

Specifies parameters for this request. The type of arg is dependent on the specific ioctl() request and device to which the ioctl call is targeted.

Description

The ioctl() routine performs a variety of control functions on devices. The functions performed are device-specific control functions. The request and arg parameters are passed to the file designated by fildes and then interpreted by the device driver. The basic input/output functions are performed through the read() and write() system calls.

Encoded in an ioctl() request is whether the parameter is an in parameter or an out parameter, and the size of the arg parameter in bytes. The macros and definitions used to specify an ioctl() request are located in the <ioctl.h> header file.


Return Values

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

Errors

[EBADF] The fildes parameter is not a valid open file descriptor.
[EINTR] A signal was caught during the ioctl() operation.
[EINVAL] The multiplexer referenced by fildes is linked (directly or indirectly) downstream from a multiplexer.
If an underlying device driver detects an error, errno might be set to one of the following values:
[EINVAL] Either the request or arg parameter is not valid.
[EIO] Some physical I/O error has occurred.
[ENOTTY] Reserved for Compaq use. The fildes parameter is not associated with a character special device, or the specified request does not apply to the type of object that the fildes parameter references.
[ENXIO] The request and arg parameters are valid for this device driver, but the service requested cannot be performed on the particular subdevice.
[ENODEV] The fildes parameter refers to a valid STREAMS device, but the corresponding device driver does not support the ioctl() function.

ntohl()

Converts longwords from network byte order to host byte order.

Format

#include <in.h>

unsigned long int ntohl (unsigned long int netlong);


Argument

netlong

A longword in network byte order. Integers in network byte order cannot be used for arithmetic computation on the OpenVMS system.

Description

This routine converts 32-bit unsigned integers from network byte order to host byte order.

The network byte order is the format in which data bytes are expected to be transmitted through a network. All hosts on a network should send data in network byte order. Not all hosts have an internal data representation format that is identical to the network byte order. The host byte order is the format in which bytes are ordered internally on a specific host. The host byte order on OpenVMS systems differs from the network order.

This routine is most often used with internet addresses. Network byte order places the byte with the most significant bits at lower addresses, whereas the OpenVMS system places the most significant bits at the highest address.

Note

The 64-bit return from OpenVMS Alpha systems has zero-extended bits in the high 32 bits of R0.

Return Value

x A longword in host byte order.

ntohs()

Converts short integers from network byte order to host byte order.

Format

#include <in.h>

unsigned short int ntohs (unsigned short int netshort);


Argument

netshort

A short integer in network byte order. Integers in network byte order cannot be used for arithmetic computation on the OpenVMS system.

Description

This routine converts 16-bit unsigned integers from network byte order to host byte order.

The network byte order is the format in which data bytes are expected to be transmitted through a network. All hosts on a network should send data in network byte order. Not all hosts have an internal data representation format that is identical to the network byte order. The host byte order is the format in which bytes are ordered internally on a specific host.

The host byte order on OpenVMS systems differs from the network order.

This routine is most often used with internet ports as returned by getservent(). Network byte order places the byte with the most significant bits at lower addresses, whereas the OpenVMS system places the most significant bits at the highest address.


Return Value

x A short integer in host byte order (OpenVMS).


Previous Next Contents Index