 |
» |
|
|
|
Provides an interface and control over magnetic tape devices. In the case of magnetic tape devices, the ioctl() function provides an interface for issuing various control commands to opened tape devices. The ioctl() operations can be used to position the magnetic tape, and to determine the tape device status.
Syntax |  |
int ioctl(fildes, request, arg)
int fildes;
int request;
void *arg;
|
Parameters |  |
- fildes
The socket descriptor.
- request
This parameter specifies which command to perform on the socket. The
commands are defined in <sys/ioctl.h>. The different commands that
are available are described below.
- FIONREAD
Gets the number of bytes that are readable from the socket. For TCP sockets, this is the total number of bytes queued to the socket. For UDP sockets, this is the total number of bytes queued in each datagram and the sum of all the source address structures. The arg parameter, will contain the address of the integer with the number of bytes readable.
- FIOSNBIO
Enables or disables non-blocking I/O for the socket. If the integer whose address is arg is not zero, then non-blocking I/O is enabled. When non-blocking I/O is enabled, subsequent read and write requests to the socket are prevented from blocking whether the request succeeds or fails. If the integer whose address is arg is zero, then non-blocking I/O is disabled.
- FIONBIO
This command is same as the FIOSNBIO command.
- FIOGNBIO
Gets the status of non-blocking i/o. If non-blocking i/o is enabled for the socket, then the integer whose address is arg is set to 1. If non-blocking i/o is disabled, the integer is set to zero.
- FIOGSAIOSTAT
If asynchronous signaling is enabled for the socket, then the integer whose address is arg is set to 1. If the asynchronous state is disabled, the integer is set to zero.
- SIOCATMARK
For SOCK_STREAM TCP sockets, upon return if the integer whose address is arg is not zero, then the inbound TCP stream has been read up to where the out-of-band data byte starts. If the integer at address arg is zero, then the inbound TCP stream has not yet been read up to where the out-of-band data byte starts. For non-TCP sockets, upon return the integer with the address arg is always zero.
- SIOCSPGRP
This command sets the process group or process ID associated with the socket to be the value of the integer whose address is arg. If the value of the integer is positive, then a signal is sent to the process with the matching process ID value when the state of the socket changes. If the value is negative, then a signal is sent to all processes that have a process group equal to the absolute value of the specified value when the socket state changes. If the value of the integer with address arg is zero, no signal is sent to any processes when the socket state changes.
- SIOCGPGRP
This command returns the process group or process ID associated with the socket in the integer whose address is arg. If the integer is positive, then the value returned corresponds to a process ID. If the integer is negative, then the value returned corresponds to all processes that have a process group equal to the absolute value of that value.
- arg
This parameter is the address of the integer that the specified request needs in order to perform its function. Depending on the type of request specified, the integer can represent a variety of values. See the appropriate request command for an explanation of the value that the integer will represent in that context.
Return Values |  |
- 0
The function completes successfully.
- -1
If an error occurs, a value of -1 is returned by the function and the
global variable errno is set with the resultant error.
Description |  |
Sockets are communication endpoints that allow processes to communicate either locally or remotely. For sockets, the ioctl() function provides an interface for setting different characteristics for a socket, and retrieving information on a socket.
Implementation Considerations |  |
There will not be any implementation defined items in the sockets portion
of ioctl().
There are no mixed environment issues for the sockets portion of ioctl().
Errors |  |
If an error occurs, errno is set to one of the following values:
EBADF | CAUSE | The argument fildes is not a valid open file descriptor. | | ACTION | Check to see if fildes has been altered or if fildes is not initialized. | EFAULT | CAUSE | The system detected a NULL address while attempting to use the arg parameter passed by the caller. | | ACTION | Check to see if the pointer used is initialized and/or not equal to NULL. | | | | EINTR | CAUSE | Once this function is executing an intrinsic, no signal interruption may occur. Signal interrupts can only occur in the library portion of the code. | | | | | ACTION | Check the state of the socket referenced by fildes. | | | | EINVAL | CAUSE | The request parameter or the arg parameter is invalid, or a socket type that is not supported was specified. | | | | | ACTION | Validate the request and arg values; check if the socket type is supported. | | | |
See Also |  |
ioctl-streams, ioctl-mag_tape(), POSIX.1
|