UNIX网络编程卷一:第十七章 ioctl
来源:互联网 发布:爱剪辑软件 编辑:程序博客网 时间:2024/06/06 07:17
ioctl函数传统上一直作为不适合归入其它精细定义类别的特性的系统借口。
POSIX致力于摆脱ioctl借口,办法是创造新的函数来取代ioctl,例如:
Unix终端接口传统上使用ioctl访问,而POSIX为终端创造了12个新函数:tcgetattr tcflush ....
但是,ioctl依然保留了不少功能,用于:获取接口信息、访问路由表、访问ARP高速缓存等。
网络程序(特别是服务器程序)经常在启动后使用ioctl获取所在主机全部网络接口的信息:接口地址、是否支持广播、是否支持多播等。
NAME ioctl - control deviceSYNOPSIS #include <sys/ioctl.h> int ioctl(int d, unsigned long request, ...);DESCRIPTION The ioctl() function manipulates the underlying device parameters of special files. In particular, many operating characteristics of character special files (e.g., terminals) may be con‐ trolled with ioctl() requests. The argument d must be an open file descriptor. The second argument is a device-dependent request code. The third argument is an untyped pointer to memory. It's traditionally char *argp (from the days before void * was valid C), and will be so named for this discussion. An ioctl() request has encoded in it whether the argument is an in parameter or out parameter, and the size of the argument argp in bytes. Macros and defines used in specifying an ioctl() request are located in the file <sys/ioctl.h>.RETURN VALUE Usually, on success zero is returned. A few ioctl() requests use the return value as an output parameter and return a nonnegative value on success. On error, -1 is returned, and errno is set appropriately.ERRORS EBADF d is not a valid descriptor. EFAULT argp references an inaccessible memory area. EINVAL Request or argp is not valid. ENOTTY d is not associated with a character special device. ENOTTY The specified request does not apply to the kind of object that the descriptor d references.
ioctl用于操作设备,该设备的描述符由d指定。第三个参数是一个指针,指针的类型依赖于request。其中与网络相关的request如下表所示:
0 0
- UNIX网络编程卷一:第十七章 ioctl
- UNIX网络编程卷一 笔记 第二章 传输层
- UNIX网络编程卷一:第八章 I/O UDP
- UNIX网络编程卷一:第十四章 高级I/O
- UNIX网络编程卷一:第二十章 广播
- UNIX网络编程卷一:第二十一章 多播
- UNIX网络编程卷一:第二十六章 线程
- Unix 网络编程卷一- 学习笔记
- unix网络编程(卷一)--安装源码
- 【计算机网络】《unix网络编程卷一》读书笔记
- unix 网络编程 卷一(unp.h)
- Unix网络编程卷一笔记
- UNIX网络编程卷一 第一章 简介
- 学习《UNIX网络编程卷一》笔记
- UNIX网络编程 -- 第十六章 ioctl操作
- UNIX网络编程卷一:第十五章 Unix域套接字
- 《UNIX网络编程 卷一》第2章:各网络协议的用途
- UNIX网络编程卷一 笔记 第三章 套接字编程简介
- hibernate 保存图片到数据库(oracle)
- 《Java网络编程》读书笔记(一)
- Linux源代码目录树结构
- 通过ApplicationContextAwareSpring实现手工加载配置的javabean
- python自动登录BAIDU,失效版
- UNIX网络编程卷一:第十七章 ioctl
- [bzoj1026][SCOI2009]windy数
- 使用synchronized和Lock对象获取对象锁
- jQuery中的datatable 插件新增一行
- HDOJ-1671-字典树
- Android官方数据绑定框架DataBinding(二)
- [NOIP2010]引水入城
- tcp ip协议笔记(4)——arp
- 聊一聊关于AIDL 那点事