Chinaunix首页 | 论坛 | 博客
  • 博客访问: 92616
  • 博文数量: 16
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 131
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-03 04:11
文章分类

全部博文(16)

文章存档

2016年(4)

2015年(10)

2014年(2)

我的朋友

分类: C/C++

2016-05-04 09:22:33

1. 函数原型

int socket(int domain, int type, int protocol);

参数介绍:
domain

点击(此处)折叠或打开

  1. /* Supported address families. */
  2. #define AF_UNSPEC 0
  3. #define AF_UNIX 1          /* Unix domain sockets */
  4. #define AF_LOCAL 1         /* POSIX name for AF_UNIX */
  5. #define AF_INET 2          /* Internet IP Protocol */
  6. #define AF_AX25 3          /* Amateur Radio AX.25 */
  7. #define AF_IPX 4           /* Novell IPX */
  8. #define AF_APPLETALK 5     /* AppleTalk DDP */
  9. #define AF_NETROM 6        /* Amateur Radio NET/ROM */
  10. #define AF_BRIDGE 7        /* Multiprotocol bridge */
  11. #define AF_ATMPVC 8        /* ATM PVCs */
  12. #define AF_X25 9           /* Reserved for X.25 project */
  13. #define AF_INET6 10        /* IP version 6 */
  14. #define AF_ROSE 11         /* Amateur Radio X.25 PLP */
  15. #define AF_DECnet 12       /* Reserved for DECnet project */
  16. #define AF_NETBEUI 13      /* Reserved for 802.2LLC project*/
  17. #define AF_SECURITY 14     /* Security callback pseudo AF */
  18. #define AF_KEY 15          /* PF_KEY key management API */
  19. #define AF_NETLINK 16
  20. #define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */
  21. #define AF_PACKET 17       /* Packet family */
  22. #define AF_ASH 18          /* Ash */
  23. #define AF_ECONET 19       /* Acorn Econet */
  24. #define AF_ATMSVC 20       /* ATM SVCs */
  25. #define AF_SNA 22          /* Linux SNA Project ( */
  26. #define AF_IRDA 23         /* IRDA sockets */
  27. #define AF_PPPOX 24        /* PPPoX sockets */
  28. #define AF_WANPIPE 25      /* Wanpipe API Sockets */
  29. #define AF_LLC 26          /* Linux LLC */
  30. #define AF_BLUETOOTH 31    /* Bluetooth sockets */
  31. #define AF_MAX 32          /* For now.. */

  32. /* Protocol families, same as address families. */
type:

点击(此处)折叠或打开

  1. enum sock_type {
  2.         SOCK_STREAM = 1,    //stream (connection) socket
  3.         SOCK_DGRAM = 2,     //datagram (conn.less) socket
  4.         SOCK_RAW = 3,       //raw socket
  5.         SOCK_RDM = 4,       //reliably-delivered message
  6.         SOCK_SEQPACKET = 5, //sequential packet socket
  7.         SOCK_PACKET = 10,   //linux specific way of getting packets at the dev level.For writing rarp and other similar things on the user level.
  8. }
protocol

点击(此处)折叠或打开

  1. /* Standard well-defined IP protocols. */
  2. enum {
  3.   IPPROTO_IP = 0,         /* Dummy protocol for TCP */
  4.   IPPROTO_ICMP = 1,       /* Internet Control Message Protocol */
  5.   IPPROTO_IGMP = 2,       /* Internet Group Management Protocol */
  6.   IPPROTO_IPIP = 4,       /* IPIP tunnels (older KA9Q tunnels use 94) */
  7.   IPPROTO_TCP = 6,        /* Transmission Control Protocol */
  8.   IPPROTO_EGP = 8,        /* Exterior Gateway Protocol */
  9.   IPPROTO_PUP = 12,       /* PUP protocol */
  10.   IPPROTO_UDP = 17,       /* User Datagram Protocol */
  11.   IPPROTO_IDP = 22,       /* XNS IDP protocol */
  12.   IPPROTO_RSVP = 46,      /* RSVP protocol */
  13.   IPPROTO_GRE = 47,       /* Cisco GRE tunnels (rfc 1701,1702) */

  14.   IPPROTO_IPV6 = 41,      /* IPv6-in-IPv4 tunnelling */

  15.   IPPROTO_ESP = 50,       /* Encapsulation Security Payload protocol */
  16.   IPPROTO_AH = 51,        /* Authentication Header protocol */
  17.   IPPROTO_PIM = 103,      /* Protocol Independent Multicast */

  18.   IPPROTO_COMP = 108,     /* Compression Header protocol */
  19.   IPPROTO_SCTP = 132,     /* Stream Control Transport Protocol */

  20.   IPPROTO_RAW = 255,      /* Raw IP packets */
  21.   IPPROTO_MAX
  22. };



阅读(1904) | 评论(0) | 转发(0) |
0

上一篇:keystone对接LDAP实践

下一篇:snmp

给主人留下些什么吧!~~