Linux socket函数 编程手册 重点分析一
2014-06-20 11:21
183 查看
man socket:
头文件和函数原型:
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
int socket(int domain, int type, int protocol);
domain参数指定通信域,具体取值定义类型都在<sys/socket.h>,现可用类型包括:
Name Purpose Man page
AF_UNIX, AF_LOCAL Local communication unix(7)
AF_INET IPv4 Internet protocols ip(7)
AF_INET6 IPv6 Internet protocols ipv6(7)
AF_IPX IPX - Novell protocols
AF_NETLINK Kernel user interface device netlink(7)
AF_X25 ITU-T X.25 / ISO-8208 protocol x25(7)
AF_AX25 Amateur radio AX.25 protocol
AF_ATMPVC Access to raw ATM PVCs
AF_APPLETALK Appletalk ddp(7)
AF_PACKET Low level packet interface packet(7)
type参数指定套接字的类型,进一步确定通信特征:
SOCK_STREAM Provides sequenced, reliable, two-way, connection-based byte streams. An out-of-band data trans‐
mission mechanism may be supported.
SOCK_DGRAM Supports datagrams (connectionless, unreliable messages of a fixed maximum length).
SOCK_SEQPACKET Provides a sequenced, reliable, two-way connection-based data transmission path for datagrams of
fixed maximum length; a consumer is required to read an entire packet with each input system call.
SOCK_RAW Provides raw network protocol access.
SOCK_RDM Provides a reliable datagram layer that does not guarantee ordering.
SOCK_PACKET Obsolete and should not be used in new programs; see packet(7).
参数protocol通常是零,标示按给定的域和套接字类型选择默认协议。当对同一域和套接字类型支持多个协议时,可以使用protocol参数选择一个特定协议:IPPROTO_TCP、IPPTOTO_UDP、IPPROTO_SCTP、IPPROTO_TIPC
接下去第二章实例分析。
头文件和函数原型:
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
int socket(int domain, int type, int protocol);
domain参数指定通信域,具体取值定义类型都在<sys/socket.h>,现可用类型包括:
Name Purpose Man page
AF_UNIX, AF_LOCAL Local communication unix(7)
AF_INET IPv4 Internet protocols ip(7)
AF_INET6 IPv6 Internet protocols ipv6(7)
AF_IPX IPX - Novell protocols
AF_NETLINK Kernel user interface device netlink(7)
AF_X25 ITU-T X.25 / ISO-8208 protocol x25(7)
AF_AX25 Amateur radio AX.25 protocol
AF_ATMPVC Access to raw ATM PVCs
AF_APPLETALK Appletalk ddp(7)
AF_PACKET Low level packet interface packet(7)
type参数指定套接字的类型,进一步确定通信特征:
SOCK_STREAM Provides sequenced, reliable, two-way, connection-based byte streams. An out-of-band data trans‐
mission mechanism may be supported.
SOCK_DGRAM Supports datagrams (connectionless, unreliable messages of a fixed maximum length).
SOCK_SEQPACKET Provides a sequenced, reliable, two-way connection-based data transmission path for datagrams of
fixed maximum length; a consumer is required to read an entire packet with each input system call.
SOCK_RAW Provides raw network protocol access.
SOCK_RDM Provides a reliable datagram layer that does not guarantee ordering.
SOCK_PACKET Obsolete and should not be used in new programs; see packet(7).
参数protocol通常是零,标示按给定的域和套接字类型选择默认协议。当对同一域和套接字类型支持多个协议时,可以使用protocol参数选择一个特定协议:IPPROTO_TCP、IPPTOTO_UDP、IPPROTO_SCTP、IPPROTO_TIPC
接下去第二章实例分析。
相关文章推荐
- Linux socket函数 编程手册 重点分析三
- Linux socket函数 编程手册 重点分析二
- C++高级编程资料汇总(参考手册+电子书+编程思想+算法分析)
- C++高级编程资料汇总(参考手册+电子书+编程思想+算法分析) ...
- 02-JDBC学习手册:JDBC编程步骤【重点重点】
- C++高级编程资料汇总(参考手册+电子书+编程思想+算法分析)
- 编程词汇不完全手册
- Oracle PL/SQL 编程手册(SQL大全)(转)
- 编程要学会绕道而行:实例分析--另一种绘制空心字的方法.
- GDI+编程中的一条错误信息及其原因分析
- 【分析】非安全编程演示之格式化字符串篇version1.1
- [转贴]编程词汇不完全手册(英中对照版)
- GDI+编程中的一条错误信息及其原因分析
- Java 编程技术中汉字问题的分析及解决
- DotNetNuke中的函数式编程手法分析
- Oracle PL/SQL 编程手册(SQL大全)(转)
- Java 编程技术中汉字问题的分析及解决
- 销售代表手册 第五章 客户拒绝分析
- Oracle PL/SQL 编程手册(SQL大全)(转)
- 一个.NET编程的作业(Shop & Products) (2-分析篇(类图与Trousers类的设计))