Fixing ioctl() usage for sockets