Talk:Ioctl

2007–2009
I think this is a fantastic article but may have to rewritten more for the general audience. I sorry I get it but some may not.


 * I'm not married to it; what was there before was inaccurate. What do you think it needs? --- tqbf  03:37, 20 November 2007 (UTC)

Hi, please add some examples of ioctl function calls. It would be nice to see the inputs and outputs. Thanks! —Preceding unsigned comment added by 206.114.9.2 (talk) 15:28, 21 October 2009 (UTC)

Complexity of ioctl
In the complexity paragraph it is said that one needs a "tangled mess of ioctls" to get an IP. That's BS. You only need one. Like so: ioctl(int sockfd, SIOCGIFADDR, struct ifreq *req); And voila, ((struct sockaddr_in *)&req.ifr_addr)->sin_addr yields the IP. Seriously, ioctls aren't complex, they are very easy to use and understand. It's only that there are hundreds of request codes(see /usr/include/linux/sockios.h on a Linux machine for a reference).

Maybe some example program should be shown.

That program below will output the IPv4 of the device 'lo' (local loopback on Linux, called lo0 on *BSD), which is of cource 127.0.0.1. Substitute lo in the macro definition with any device you want the IPv4 address from. The program will compile cleanly and can be run without rootr ights on Linux(and probably every other UNIX-like OS). Maybe that code, with (now added) commentary, could make it as an example of ioctl usage?

80.226.24.13 (talk) 21:47, 25 January 2013 (UTC)