Anyways, I have discovered that some of the code in this book is suffering from some bit-rot. Specifically in section 17.6 of the third edition some code is presented that allows the programmer to traverse the list of network interfaces on the local machine. This code uses uses ioctl(...., SIOCGIFCONF, ...) to get the information.
The source of the bit-rot is that Stevens' code made some assumptions about the size of (struct ifreq).....and these assumptions are no longer valid, at least, not for me who is running a relatively modern Linux 2.6 box.
So, I've come up with a patch. I'm pretty pleased with my patch, because
- the code can be fixed.
- the code can be simplified.
- the code can be made to be more portable and to still work even if this union is changed in the future.
1 comment:
Post a Comment