net device and ioctls communication with sockets - Linux

This is a discussion on net device and ioctls communication with sockets - Linux ; Hi all, I'm wondering why, in order to talk to an net device, I need to open a socket. Even more, I don't understand the reason why this socket has to be AF_INET instead of a std unix socket... which ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: net device and ioctls communication with sockets

  1. net device and ioctls communication with sockets

    Hi all,
    I'm wondering why, in order to talk to an net device, I need to open a
    socket. Even more, I don't understand the reason why this socket has
    to be AF_INET instead of a std unix socket... which seems more
    reasonable to me..
    Thanks in advance!

    RM

  2. Re: net device and ioctls communication with sockets

    InuY4sha writes:

    >Hi all,
    >I'm wondering why, in order to talk to an net device, I need to open a
    >socket. Even more, I don't understand the reason why this socket has
    >to be AF_INET instead of a std unix socket... which seems more
    >reasonable to me..
    >Thanks in advance!


    Read about address families:

    http://beej.us/guide/bgnet/output/ht...ructsdata.html

    --
    Chris.

  3. Re: net device and ioctls communication with sockets

    > Read about address families:
    >
    > http://beej.us/guide/bgnet/output/ht...ructsdata.html
    >
    > --
    > Chris.


    I gave a look (read once) that link.. but didn't find anything really
    addressing my question... *why* I should use a AF_INET socket instead
    than a unix one ...
    Maybe I'm missing the big picture... commonly the AF_INET socket is
    used to talk to the internet, while AF_UNIX are used for inter process
    communication on the same machine ... This havig been said, my guess
    is that *actually* AF_INET are "special" sockets that allow the
    userspace apps to talk to NETWORK INTERFACES, in general, not
    specificly to the internet.
    Therefore we can use these interfaces *either* to send a packet
    *through* the interface, or to get/set information about the interface
    (such as a file descriptor to use for the subsequent call to an
    ioctl).. .while AF_UNIX cannot..
    Is this closer to a correct answer ?
    Thankx in advance and excuse my scarce knowledge

  4. Re: net device and ioctls communication with sockets

    InuY4sha schrieb:
    >
    > I gave a look (read once) that link.. but didn't find anything really
    > addressing my question... *why* I should use a AF_INET socket instead
    > than a unix one ...
    > Maybe I'm missing the big picture... commonly the AF_INET socket is
    > used to talk to the internet, while AF_UNIX are used for inter process
    > communication on the same machine ... This havig been said, my guess
    > is that *actually* AF_INET are "special" sockets that allow the
    > userspace apps to talk to NETWORK INTERFACES, in general, not
    > specificly to the internet.
    >

    You talk about the SIOCGIF* ioctls, right? I would say that's a hack to
    allow an easy access some useful information about an already opened
    socket. It's seem natural to me these ioctls do only work if the socket is
    bound to an actual network interface -- PF_UNIX isn't.

    One could argue the whole socket() system call is a hack to get around the
    major/minor device number limitation of the usual device interface. If /dev
    had been designed differently in the past, we probably ended up opening a
    network connection just with

    fd=open("/dev/socket/inet/stream/tcp",O_RDWR)

    or similar.

    Kind regards

    Jan


+ Reply to Thread