ioctl() - control a socket or file
#include <sys/ioctl.h>
#include <stropts.h>
int ioctl (int fd, int command, ...);
The ioctl(2) function manipulates the underlying device parameters. In particular, many operating characteristics of terminals and sockets may be controlled with ioctl(2) requests. The argument fd must be an open file descriptor.
Encoded in an ioctl(2) request is whether the argument is an in parameter or an out parameter, and the size of the remaining arguments in bytes.
The possible values for command are defined in <sys/ioctl.h> and include:
The call
ioctl(d, FIONBIO, NULL)
is equivalent to a call to
fcntl(d, F_SETFL, O_NONBLOCK)
except that for each fcntl(2) call, all of the flag values must set, while the ioctl(2) call allows you to set only one flag.
The return value of the ioctl(2) depends upon the command. If an error occurs, it returns -1 and sets errno to indicate the error.
The ioctl(2) call will fail if:
Traditional implementations of ioctl(2) also handle the terminal interface. For terminal manipulation (traditionally handled with TIOCGETD, TIOCSETD, TIOCGETP, and TIOCSETP or with stty() and gtty()), use the POSIX calls tcgetattr(2), tcsetattr(2), cfgetispeed(3), cfsetispeed(3), cfgetospeed(3), and cfsetospeed(3) to manipulate the termios structure, instead.
execve(2)
fcntl(2)