Chapter Contents

Previous

Next
ioctl

ioctl



Controls Operating Characteristics of Socket Descriptors

Portability: UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
PORTABILITY
RELATED FUNCTIONS


SYNOPSIS

#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <if.h>

int ioctl(int s, unsigned long cmd, void *data);


DESCRIPTION

ioctl controls or queries the operating characteristics of socket descriptor s . data points to the data that are associated with command cmd .

The following commands are valid:

FIONBIO
controls non-blocking I/O for socket descriptor s , and data points to an integer. If *data is 0 , ioctl clears non-blocking I/O. If *data is not 0 , s is set for non-blocking I/O. Calls that cannot complete immediately return a -1 with errno set to EWOULDBLOCK .

FIONREAD
stores the number of readable bytes for s ; data points to an integer, which is set to the number of readable characters for s .

SIOCATMARK
checks to see if s is pointing to out-of-band data. data points to an integer, which is set to 1 if s points to out-of-band data. Otherwise, *data is set to 0 . Use this option for TCP sockets where out-of-band data are delivered inline. Refer to "Out-of-Band Data" in Chapter 6, "Berkeley Sockets," in UNIX Network Programming.

SIOCGIFADDR
stores the network interface address. data points to an ifreq structure that is defined in <if.h> . The address is returned in the if_addr field.

SIOCGIFBRDADDR
stores the network interface broadcast address. data points to an ifreq structure that is defined in <if.h> . The address is returned in the if_broadaddr field.

SIOCGIFCONF
stores a network interface configuration list. data points to an ifconf structure that is defined in <if.h> . On input, the structure specifies a buffer into which the list is placed. The ifc_buf field should point to the buffer. The ifc_len field should contain its length in bytes.

SIOCGIFDSTADDR
stores the network destination interface address. data points to an ifreq structure that is defined in <if.h> . For point-to-point connections, this option stores the address of the remote interface or destination. The address is stored in the if_dstadaddr field.

SIOCGIFFLAGS
stores the network interface flags. data points to an ifreq structure that is defined in <if.h> . The flags provide information about the interface and its current state, such as whether the interface is point-to-point and whether it is currently up. The flags are stored in the ifr_flags field of the ifreq structure. The names of the flags begin with IFF; they are listed in the <if.h> header file.

SIOCGIFNETMASK
stores the network interface network mask. data points to an ifreq structure that is defined in <if.h> . The address is returned in the if_addr field.

Additional options may be supported by some TCP/IP software products. Refer to your software documentation for details.

Note:    If integrated sockets are in use, the ioctl function simply calls the w_ioctl USS system call.  [cautionend]


RETURN VALUE

If ioctl succeeds, it returns a 0 . Otherwise, it returns a -1 , and sets errno to indicate the type of error.


PORTABILITY

ioctl is portable to other environments, including most UNIX systems, that implement BSD sockets. Unlike the BSD UNIX ioctl call, the SAS/C version of ioctl controls only sockets.


RELATED FUNCTIONS

fcntl getsockopt , setsockopt


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.