Welcome to EZDefinition.com
Technological Concepts, Abbreviations & Definitions
Main Menu
Main categories
  • Operating Systems
  • Computer Hardware
  • Internet
  • Programming Languages
  • Multimedia
  • Software
  • Security and Encryption
  • Communications and Networking
  • Organizations
  • Books
  • Databases
  • Games
  • E-commerce

    [an error occurred while processing this directive]

  • EZDefinition Sponsor
    Please visit our sponsor Parosoft.com
    Related Links to Device control: ioctl
    [an error occurred while processing this directive]
    Device control: ioctl
    [an error occurred while processing this directive]
    Computer Technologies  Programming Languages  C Device control: ioctl

    Device control: ioctl

    Device control: ioctl

    The C function ´ioctl' (I/O control) is used to send special control commands to devices like the disk and the network interface. The syntax of the function is
    int ioctl(fd, request, arg)
    int fd, request;
    long arg;
    The first parameter is normally as device handle or socket descriptor. The second is a control parameter. Lists of valid control parameters are normally defined in the system ´include' files for a particular device. They are device and system dependent so you need a local manual and som detective work to find out what they are. The final parameter is a pointer to a variable which receives return data from the device.
    ´ioctl' commands are device specific, by their nature. The commands for the ethernet interface device are only partially standardized, for example. We could read the ethernet device (which is called ´le0' on a Sun workstation), using the following command:

    # include <sys/socket.h> /* Typical includes for internet */
    # include <sys/ioctl.h>
    # include <net/if.h>
    # include <netinet/in.h>
    # include <arpa/inet.h>
    # include <netdb.h>
    # include <sys/protosw.h>
    # include <net/route.h>

    struct ifreq IFR;
    int sk;
    struct sockaddr_in sin;

    strcpy(IFR.ifr_name,"le0");
    IFR.ifr_addr.sa_family = AF_INET;

    if ((sk = socket(AF_INET,SOCK_DGRAM,IPPROTO_IP)) == -1)
    {
    perror("socket");
    exit(1);
    }

    if (ioctl(sk,SIOCGIFFLAGS, (caddr_t) &IFR) == -1)
    {
    perror ("ioctl");
    exit(1);
    }
    We shall not go into the further details of ´ioctl', but simply note its role in system programming.


    [an error occurred while processing this directive]

    [an error occurred while processing this directive]
     

    All Rights Reserved

    Terms of usage   Please read our privacy stetment
    Copyright © 1999-2006 EZDefinition.com

     

    [an error occurred while processing this directive]