United States |
Previous | Contents | Index |
Returns the Internet network address portion of an Internet address.
#include <in.h>#include <inet.h>
int inet_netof (struct in_addr in);
in
An Internet address.
This routine returns the Internet network address (NET) portion of a full Internet address.
x The Internet network portion of an Internet address in host byte order.
Converts a text string representing an Internet network address in the standard Internet "." notation into an Internet network address as machine-format integer values.
#include <in.h>#include <inet.h>
int inet_network (char *cp);
cp
A pointer to an ASCIZ (null-terminated) character string containing a network address in the standard Internet "." format.
This routine returns an Internet network address as machine-format integer values when given as its argument an ASCIZ string representing the address in the Internet standard "." notation.
--1 Indicates that cp does not point to a proper Internet network address. x An Internet network address as machine-format integer values.
Converts an Internet address into a text string representing the address in the standard Internet "." notation.
#include <in.h>#include <inet.h>
char *inet_ntoa (struct in_addr in);
in
An Internet address in network byte order.
This routine converts an Internet address into an ASCIZ (null-terminated) string representing that address in the standard Internet "." notation.
Warning
Arguments should not be passed as integers because of how Compaq C handles struct arguments.Because the string is returned in a static buffer that will be overwritten by successive calls to inet_ntoa , it is recommended to copy the string to a safe place.
x A pointer to a string containing the Internet address in "." notation.
Controls socket operations only.
#include <ioctl.h>int ioctl (int d, unsigned long request, void *arg);
d
Specifies the file descriptor of the requested device.request
Specifies the ioctl command performed on the device.arg
Specifies parameters for this request. The type of arg is dependent on the specific ioctl request and device to which the ioctl is targeted.
The ioctl routine performs a variety of operations on sockets.An ioctl request has encoded in it, whether the parameter is an "in" parameter or "out" parameter, and the size of the arg parameter in bytes. The ioctl request is defined in the <ioctl.h> header file.
0 Indicates success. --1 Indicates an error; further specified in the global errno .
If the ioctl routine fails, errno is set to one of the following values:
- EBADF -- The d parameter is not a valid descriptor.
- ENOTTY -- The d parameter is not associated with a character special device, or the specified request does not apply to the kind of object that the d parameter references.
- EINVAL -- Either the request or the arg parameter is not valid.
Sets the maximum limit of outstanding connection requests for a socket that is connection-oriented.
int listen (int s, int backlog);
s
A socket descriptor of type SOCK_STREAM that has been created using socket .backlog
The maximum number of pending connections that may be queued on the socket at any given time. The maximum cannot exceed 5.
This routine creates a queue for pending connection requests on socket s with a maximum size of backlog. Connections may then be accepted with accept .If a connection request arrives with the queue full (more than backlog connection requests pending), the client will receive a timeout.
See also accept , connect , and socket in this section.
0 Indicates success. --1 Indicates an error; errno is set to one of the following values:
- EBADF -- The socket descriptor is invalid.
- ENOTSOCK -- The socket descriptor references a file, not a socket.
- EOPNOTSUPP -- The socket is not of a type that supports the operation listen .
Converts longwords from network to host byte order.
#include <in.h>unsigned long int ntohl (unsigned long int netlong);
netlong
A longword in network byte order. Integers in network byte order cannot be used for arithmetic computation on VAX systems.
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 supposed to be transmitted through a network. All hosts on a network must 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 VAX systems differs from the network order.
This routine is most often used with Internet addresses and ports as returned by gethostent and getservent , and when manipulating values in the structures. Network byte order places the byte with the most significant bits at lower addresses; VAX systems place the most significant bits at the highest address.
x A longword in host byte order.
Converts short integers from network to host byte order.
#include <in.h>unsigned short int ntohs (unsigned short int netshort);
netshort
A short integer in network byte order. Integers in network byte order cannot be used for arithmetic computation on VAX systems.
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 supposed to be transmitted through a network. All hosts on a network must 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 VAX systems differs from the network order.
This routine is most often used with Internet addresses and ports as returned by gethostent and getservent , and when manipulating values in the structures. Network byte order places the byte with the most significant bits at lower addresses; VAX systems place the most significant bits at the highest address.
x A short integer in host (VAX) byte order.
Reads bytes from a socket or file and places them in a buffer.
#include <unixio.h>int read (int d, void *buffer, int nbytes);
d
A descriptor that must refer to a socket or file currently opened for reading.buffer
The address of contiguous storage in which the input data is placed.nbytes
The maximum number of bytes involved in the read operation.
If the end-of-file is not reached, the read routine returns nbytes. If the end-of-file occurs during the read routine, it returns the number of bytes read.Upon successful completion, read returns the number of bytes actually read and placed in the buffer.
See also socket in this section.
x The number of bytes read and placed in the file. --1 Indicates an error; errno is set to one of the following:
- EBADF -- The socket descriptor is invalid.
- EFAULT -- The buffer points outside the allocated address space.
- EINVAL -- The nbytes argument is negative.
- EWOULDBLOCK -- The NBIO socket option (nonblocking) flag is set for the socket or file descriptor and the process would be delayed in the read operation.
Receives bytes from a connected socket and places them into a buffer.
#include <socket.h>int recv (int s, char *buf, int len, int flags);
(_DECC_V4_SOURCE) ssize_t recv (int s, void *buf, size_t len, int flags);
(NOT _DECC_V4_SOURCE)
s
A socket descriptor that was created as the result of a call to accept or connect .buf
A pointer to a buffer into which received data will be placed.len
The size of the buffer pointed to by buf.flags
A bit mask that may contain one or more of MSG_OOB and MSG_PEEK . It is built by ORing the appropriate values together.The MSG_OOB flag allows out-of-band data to be received. If out-of-band data is available, it will be read before any other data that is available. If no out-of-band data is available, the MSG_OOB flag is ignored. Out-of-band data can be sent using send , sendmsg , and sendto .
The MSG_PEEK flag allows you to peek at the data that is next in line to be received without removing it from the system's buffers.
This routine receives data from a connected socket. To receive data on an unconnected socket, use the recvfrom or recvmsg routines. The received data is placed in the buffer buf.Data is sent by the socket's peer using the send , sendmsg , or sendto routines.
You may use the select routine to determine when more data arrives.
If no data is available at the socket, the receive call waits for data to arrive, unless the socket is nonblocking in which case a --1 is returned with the external variable errno set to EWOULDBLOCK .
See also read , send , sendmsg , sendto , and socket in this section.
x The number of bytes received and placed in buf. 0 Indicates that a connection is broken or reset by its peer. --1 Indicates an error; errno is set to one of the following:
- EBADF -- The socket descriptor is invalid.
- ENOTSOCK -- The descriptor references a file, not a socket.
- EPIPE -- An attempt was made to write to a socket that is not open for reading by any process.
- EWOULDBLOCK -- The NBIO socket option (nonblocking) flag is set for the socket or file descriptor and the process would be delayed in the read operation.
- EFAULT -- The data was specified to be received into a non-existent or protected part of the process address space.
Receives bytes from a socket from any source.
#include <socket.h>Routine Variants This socket routine has a variant named __bsd44_recvfrom . Enabled by defining _SOCKADDR_LEN , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.int recvfrom (int s, char *buf, int len, int flags, struct sockaddr *from, int *fromlen)
; (_DECC_V4_SOURCE) ssize_t recvfrom (int s, void *buf, size_t len, int flags, struct sockaddr *from, size_t *fromlen)
; (NOT _DECC_V4_SOURCE)
s
A socket descriptor that has been created with socket and bound to a name using bind or as a result of accept .buf
A pointer to a buffer into which received data will be placed.len
The size of the buffer pointed to by buf.flags
A bit mask that may contain one or more of MSG_OOB and MSG_PEEK . It is built by ORing the appropriate values together.The MSG_OOB flag allows out-of-band data to be received. If out-of-band data is available, it will be read before any other data that is available. If no out-of-band data is available, the MSG_OOB flag is ignored. Out-of-band data can be sent using send , sendmsg , and sendto .
The MSG_PEEK flag allows you to peek at the data that is next in line to be received without actually removing it from the system's buffers.
from
If from is nonzero, from is a buffer into which recvfrom places the address (structure) of the socket from which the data is received. If from was 0, the address will not be returned.fromlen
Points to an integer containing the size of the buffer pointed to by from. On return, the integer is modified to contain the actual length of the socket address structure returned.
This routine allows a named, unconnected socket to receive data. The data is placed in the buffer pointed to by buf, and the address of the sender of the data is placed in the buffer pointed to by from if from is non-NULL. The structure that from points to is assumed to be as large as the sockaddr structure. See <socket.h> for a description of the sockaddr structure.To receive bytes from any source, the sockets need not be connected to another socket.
You may use the select routine to determine if data is available.
If no data is available at the socket, the recv call waits for data to arrive, unless the socket is nonblocking, in which case a --1 is returned with the external variable errno set to EWOULDBLOCK .
See also read , send , sendmsg , sendto , and socket in this section.
x The number of bytes of data received and placed in buf. --1 Indicates an error; errno is set to one of the following values:
- EBADF -- The socket descriptor is invalid.
- ENOTSOCK -- The socket descriptor references a file, not a socket.
- EPIPE -- An attempt was made to write to a socket that is not open for reading by any process.
- EWOULDBLOCK -- The NBIO (nonblocking) flag is set for the socket descriptor and the process would be delayed in the write operation.
- EFAULT -- The data was specified to be received into a non-existent or protected part of the process address space.
Receives bytes on a socket and places them into scattered buffers..
#include <socket.h>Routine Variants This socket routine has a variant named __bsd44_recvmsg . Enabled by defining _SOCKADDR_LEN , this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.int recvmsg (int s, struct msghdr msg[], int flags);
s
A socket descriptor that has been created with socket .msg
A msghdr structure. See <socket.h> for a description of the msghdr structure.flags
A bit mask that may contain one or more of MSG_OOB and MSG_PEEK . It is built by ORing the appropriate values together.The MSG_OOB flag allows out-of-band data to be received. If out-of-band data is availiable, it will be read before any normal data that is available. If no out-of-band data is available, the MSG_OOB flag is ignored. Out-of-band data can be sent using send , sendmsg , and sendto .
The MSG_PEEK flag allows you to peek at the data that is next in line to be received without actually removing it from the system's buffers.
This routine may be used with any socket, whether it is in a connected state or not. It receives data sent by a call to sendmsg , send , or sendto . The message is scattered into several user buffers if such buffers are specified.To receive data, the socket need not be connected to another socket.
When the iovec[iovcnt] array specifies more than one buffer, the input data is scattered into iovcnt buffers as specified by the members of the iovec array:
iov[0], iov[1], ..., iov[iovcnt]When a message is received, it is split among the buffers by filling the first buffer in the list, then the second, and so on, until either all of the buffers are full or there is no more data to be placed in the buffers.
When a message is sent, the first buffer is copied to a system buffer and then the second buffer is copied, followed by the third buffer and so on, until all the buffers are copied. After the data is copied, the protocol will send the data to the remote host at the appropriate time, depending upon the protocol.
You may use the select routine to determine when more data arrives.
See also read , send , and socket in this section.
x The number of bytes returned in the msg_iov buffers. --1 Indicates an error; errno is set to one of the following values:
- EBADF -- The socket descriptor is invalid.
- ENOTSOCK -- The socket descriptor references a file, not a socket.
- EPIPE -- An attempt was made to write to a socket that is not open for reading by any process.
- EWOULDBLOCK -- The NBIO (nonblocking) flag is set for the socket descriptor and the process would be delayed in the write operation.
- EINTR -- The receive was interrupted by delivery of a signal before any data was available for the receive.
- EFAULT -- The data was specified to be received into a non-existent or protected part of the process address space.
Previous | Next | Contents | Index |
|