Controls I/O requests to obtain network information. Format #include <ioctl.h> int ioctl ( int s, int request, ... /* arg */ );
1 – Argument
s Specifies the socket descriptor of the requested network device. request Specifies the type of ioctl command to be performed on the device. The request types are grouped as follows: o Socket operations o File operations o Interface operations o ARP cache operations o Routing table operations Refer to IOCTL Requests for a complete list of supported IOCTL commands. arg Specifies arguments for this request. The type of arg is dependent on the specific ioctl() request and device to which the ioctl() call is targeted.
2 – Description
This function performs a variety of device-specific functions. The request and arg arguments are passed to the file designated by the s argument and then interpreted by the device driver. The basic I/O functions are performed through the read() and write() functions. Encoded in an ioctl() request is whether the argument is an "in" argument or an "out" argument, and the size of the arg argument in bytes. The macros and definitions used to specify an ioctl() request are located in the IOCTL.H header file.
3 – Return Values
-1 Error; errno is set to indicate the error.
4 – Errors
EBADF The s argument is not a valid socket descriptor. EINTR A signal was caught during the ioctl() operation. If an underlying device driver detects an error, errno might be set to one of the following values: EINVAL Either the request or the arg argument is not valid. ENOTTY Reserved for HP use. The s argument is not associated with a network device, or the specified request does not apply to the specific network device. ENXIO The request and arg arguments are valid for this device driver, but the service requested cannot be performed on the device.