From: http://blog.csdn.net/jasonm2008/article/details/4016292

int setsockopt(
  SOCKET
s,
  int
level,
  int
optname,
  const char*
optval,
  int
optlen
);

对于这个函数的level级别的参数到底有哪些, optname ,对应的又有哪些,一直很纳闷,终于今天抽空看了下msdn,leve ---- opt name  -- optval 三者之间的对应关系参数弄明白了,贴在这里,供大家一起分享!

IPPROTO_IP

IPPROTO_IPV6

IPPROTO_RM

IPPROTO_TCP

IPPROTO_UDP

NSPROTO_IPX

SOL_APPLETALK

SOL_IRLMP

SOL_SOCKET

/* Option to use with [gs]etsockopt at theIPPROTO_IP level*/

#defineIP_OPTIONS      1 /* set/get IP options */

#defineIP_HDRINCL      2 /* header is included with data */

#defineIP_TOS          3 /* IP type of service and preced*/

#defineIP_TTL          4 /* IP time to live */

#defineIP_MULTICAST_IF     9 /* set/get IP multicast i/f  */

#defineIP_MULTICAST_TTL       10 /* set/get IP multicast ttl */

#defineIP_MULTICAST_LOOP      11 /*set/get IP multicast loopback */

#defineIP_ADD_MEMBERSHIP      12 /* add an IP group membership */

#defineIP_DROP_MEMBERSHIP     13/* drop an IP group membership */

#defineIP_DONTFRAGMENT     14 /* don't fragment IP datagrams */

#defineIP_ADD_SOURCE_MEMBERSHIP  15 /* join IP group/source */

#defineIP_DROP_SOURCE_MEMBERSHIP 16 /* leave IP group/source */

#defineIP_BLOCK_SOURCE           17 /* block IP group/source */

#defineIP_UNBLOCK_SOURCE         18 /* unblock IP group/source */

#defineIP_PKTINFO                19 /* receive packet information for ipv4*/

#defineIP_RECEIVE_BROADCAST      22 /* allow/block broadcast reception */

/* Option to use with [gs]etsockopt at theIPPROTO_IPV6 level */

#defineIPV6_HDRINCL            2  /* Header is included with data */

#defineIPV6_UNICAST_HOPS       4  /* Set/get IP unicast hop limit */

#defineIPV6_MULTICAST_IF       9  /* Set/get IP multicast interface */

#defineIPV6_MULTICAST_HOPS     10 /* Set/get IP multicast ttl */

#defineIPV6_MULTICAST_LOOP     11 /* Set/get IP multicast loopback */

#defineIPV6_ADD_MEMBERSHIP     12 /* Add an IP group membership */

#defineIPV6_DROP_MEMBERSHIP    13 /* Drop an IP group membership */

#defineIPV6_JOIN_GROUP         IPV6_ADD_MEMBERSHIP

#defineIPV6_LEAVE_GROUP        IPV6_DROP_MEMBERSHIP

#defineIPV6_PKTINFO            19 /* Receive packet information for ipv6 */

#defineIPV6_HOPLIMIT           21 /* Receive packet hop limit */

#defineIPV6_PROTECTION_LEVEL   23 /* Set/get IPv6 protection level */

/* Values of IPV6_PROTECTION_LEVEL*/

#definePROTECTION_LEVEL_UNRESTRICTED  10  /* For peer-to-peer apps

#definePROTECTION_LEVEL_DEFAULT       20  /* Default level         */

#definePROTECTION_LEVEL_RESTRICTED    30  /* For Intranet apps     */

/* Option to use with [gs]etsockopt at the IPPROTO_UDP level*/

#defineUDP_NOCHECKSUM  1

#defineUDP_CHECKSUM_COVERAGE   20  /* Set/get UDP-Lite checksum coverage */

/* Option to use with [gs]etsockopt at the IPPROTO_TCP level */

#define  TCP_EXPEDITED_1122 0x0002

 

level = SOL_SOCKET

Value

Type

Meaning

SO_BROADCAST

BOOL

Enables transmission and receipt of broadcast messages on the socket.

SO_CONDITIONAL_ACCEPT

BOOL

Enables sockets to delay the acknowledgment of a connection until after the WSAAccept condition function is called.

SO_DEBUG

BOOL

Records debugging information.

SO_DONTLINGER

BOOL

Does not block close waiting for unsent data to be sent. Setting this option is equivalent to setting SO_LINGER with l_onoff set to zero.

SO_DONTROUTE

BOOL

Does not route: sends directly to interface. Succeeds but is ignored on AF_INET sockets; fails on AF_INET6 sockets with WSAENOPROTOOPT. Not supported on ATM sockets (results in an error).

SO_GROUP_PRIORITY

int

Reserved.

SO_KEEPALIVE

BOOL

Sends keep-alives. Not supported on ATM sockets (results in an error).

SO_LINGER

LINGER

Lingers on close if unsent data is present.

SO_OOBINLINE

BOOL

Receives OOB data in the normal data stream. (See section Protocol Independent Out-Of-band Data for a discussion of this topic.)

SO_RCVBUF

int

Specifies the total per-socket buffer space reserved for receives. This is unrelated to SO_MAX_MSG_SIZE or the size of a TCP window.

SO_REUSEADDR

BOOL

Allows the socket to be bound to an address that is already in use. (See bind.) Not applicable on ATM sockets.

SO_EXCLUSIVEADDRUSE

BOOL

Enables a socket to be bound for exclusive access. Does not require administrative privilege.

SO_SNDBUF

int

Specifies the total per-socket buffer space reserved for sends. This is unrelated to SO_MAX_MSG_SIZE or the size of a TCP window.

PVD_CONFIG

Service Provider Dependent

This object stores the configuration information for the service provider associated with socket s. The exact format of this data structure is service provider specific.

level = IPPROTO_TCP1

Value

Type

Meaning

TCP_NODELAY

BOOL

Disables the Nagle algorithm for send coalescing.

1     included for backward compatibility with Windows Sockets 1.1

level = NSPROTO_IPX

Note  Windows NT supports all IPX options. Windows Me/98/95 support only the following options:

Note  IPX_PTYPE
IPX_FILTERPTYPE
IPX_DSTYPE
IPX_RECVHDR
IPX_MAXSIZE (used with the getsockopt function)
IPX_ADDRESS (used with the getsockopt function)

Value

Type

Meaning

IPX_PTYPE

int

Sets the IPX packet type.

IPX_FILTERPTYPE

int

Sets the receive filter packet type

IPX_STOPFILTERPTYPE

int

Stops filtering the filter type set with IPX_FILTERTYPE

IPX_DSTYPE

int

Sets the value of the data stream field in the SPX header on every packet sent.

IPX_EXTENDED_ADDRESS

BOOL

Sets whether extended addressing is enabled.

IPX_RECVHDR

BOOL

Sets whether the protocol header is sent up on all receive headers.

IPX_RECEIVE_BROADCAST

BOOL

Indicates broadcast packets are likely on the socket. Set to TRUE by default. Applications that do not use broadcasts should set this to FALSE for better system performance.

IPX_IMMEDIATESPXACK

BOOL

Directs SPX connections not to delay before sending an ACK. Applications without back-and-forth traffic should set this to TRUE to increase performance.

BSD options not supported for setsockopt are shown in the following table.

Value

Type

Meaning

SO_ACCEPTCONN

BOOL

Socket is listening.

SO_RCVLOWAT

int

Receives low watermark.

SO_RCVTIMEO

int

Receives time-out in milliseconds (available in the Microsoft implementation of Windows Sockets 2).

SO_SNDLOWAT

int

Sends low watermark.

SO_SNDTIMEO

int

Sends time-out in milliseconds (available in the Microsoft implementation of Windows Sockets 2).

SO_TYPE

int

Type of the socket.

SO_CONDITIONAL_ACCEPT

Setting this socket option to TRUE delays the acknowledgment of a connection until after the WSAAccept condition function is called. If FALSE, the connection may be accepted before the condition function is called, but the connection will be disconnected if the condition function rejects the call. This option must be set before calling the listen function, otherwise WSAEINVAL is returned. SO_CONDITIONAL_ACCEPT is only supported for TCP and ATM.

TCP sets SO_CONDITIONAL_ACCEPT to FALSE by default, and therefore by default the connection will be accepted before the WSAAccept condition function is called. When set to TRUE, the conditional decision must be made within the TCP connection time-out. CF_DEFER connections are still subject to the time-out.

ATM sets SO_CONDITIONAL_ACCEPT to TRUE by default.

SO_DEBUG

Windows Sockets service providers are encouraged (but not required) to supply output debug information if the SO_DEBUG option is set by an application. The mechanism for generating the debug information and the form it takes are beyond the scope of this document.

SO_GROUP_PRIORITY

Reserved for future use with socket groups. Group priority indicates the relative priority of the specified socket relative to other sockets within the socket group. Values are nonnegative integers, with zero corresponding to the highest priority. Priority values represent a hint to the underlying service provider about how potentially scarce resources should be allocated. For example, whenever two or more sockets are both ready to transmit data, the highest priority socket (lowest value for SO_GROUP_PRIORITY) should be serviced first with the remainder serviced in turn according to their relative priorities.

SO_KEEPALIVE

An application can request that a TCP/IP provider enable the use of keep-alive packets on TCP connections by turning on the SO_KEEPALIVE socket option. A Windows Sockets provider need not support the use of keep-alives. If it does, the precise semantics are implementation-specific but should conform to section 4.2.3.6 of RFC 1122: Requirements for Internet Hosts—Communication Layers. If a connection is dropped as the result of keep-alives the error code WSAENETRESET is returned to any calls in progress on the socket, and any subsequent calls will fail with WSAENOTCONN.

SO_LINGER

The SO_LINGER option controls the action taken when unsent data is queued on a socket and a closesocket is performed. See closesocket for a description of the way in which the SO_LINGER settings affect the semantics of closesocket. The application sets the desired behavior by creating a LINGER structure (pointed to by the optval parameter) with these members l_onoff and l_linger set appropriately.

SO_REUSEADDR

By default, a socket cannot be bound (see bind) to a local address that is already in use. On occasion, however, it can be necessary to reuse an address in this way. Since every connection is uniquely identified by the combination of local and remote addresses, there is no problem with having two sockets bound to the same local address as long as the remote addresses are different. To inform the Windows Sockets provider that a bind on a socket should not be disallowed because the desired address is already in use by another socket, the application should set the SO_REUSEADDR socket option for the socket before issuing the bind. The option is interpreted only at the time of the bind. It is therefore unnecessary and harmless to set the option on a socket that is not to be bound to an existing address. Setting or resetting the option after the bind has no effect on this or any other socket.

SO_RCVBUF and SO_SNDBUF

When a Windows Sockets implementation supports the SO_RCVBUF and SO_SNDBUF options, an application can request different buffer sizes (larger or smaller). The call to setsockopt can succeed even when the implementation did not provide the whole amount requested. An application must call getsockopt with the same option to check the buffer size actually provided.

SO_RCVTIMEO and SO_SNDTIMEO

When using the recv function, if no data arrives during the period specified in SO_RCVTIMEO, the recv function completes. In Windows versions prior to Windows 2000, any data received subsequently fails with WSAETIMEDOUT. In Windows 2000 and later, if no data arrives within the period specified in SO_RCVTIMEO the recv function returns WSAETIMEDOUT, and if data is received, recv returns SUCCESS.

If a send or receive operation times out on a socket, the socket state is indeterminate, and should not be used; TCP sockets in this state have a potential for data loss, since the operation could be canceled at the same moment the operation was to be completed.

PVD_CONFIG

This object stores the configuration information for the service provider associated with the socket specified in the s parameter. The exact format of this data structure is specific to each service provider.

TCP_NODELAY

The TCP_NODELAY option is specific to TCP/IP service providers. The Nagle algorithm is disabled if the TCP_NODELAY option is enabled (and vice versa). The process involves buffering send data when there is unacknowledged data already in flight or buffering send data until a full-size packet can be sent. It is highly recommended that TCP/IP service providers enable the Nagle Algorithm by default, and for the vast majority of application protocols the Nagle Algorithm can deliver significant performance enhancements. However, for some applications this algorithm can impede performance, and TCP_NODELAY can be used to turn it off. These are applications where many small messages are sent, and the time delays between the messages are maintained. Application writers should not set TCP_NODELAY unless the impact of doing so is well-understood and desired because setting TCP_NODELAY can have a significant negative impact on network and application performance.

格式太烂,请见谅!!!

setsockopt , getsoctopt 函数的Level 参数和 name 参数对应表!!!相关推荐

  1. python函数用法详解2(变量的作用域(全局变量、局部变量)、共享全局变量、函数返回值、函数的参数(位置参数、关键字参数、默认参数、不定长参数)、拆包、交换变量值、引用、可变和不可变类型)

    1. 变量作⽤域         变量作⽤域指的是变量⽣效的范围,主要分为两类:局部变量和全局变量. 局部变量         定义在函数体内部的变量,即只在函数体内部⽣效. def testA(): ...

  2. pandas使用read_csv函数读取文件时指定数据列的数据类型、pandas使用read_csv函数读取文件时通过keep_default_na参数设置缺失值替换为空字符串

    pandas使用read_csv函数读取文件时指定数据列的数据类型.pandas使用read_csv函数读取文件时通过keep_default_na参数设置缺失值替换为空字符串 目录

  3. R语言merge函数全连接dataframe数据(Full (outer) join)、merge函数进行全连接必须将参数all设置为true(all=TRUE)、默认merge函数通过公共列名合并数

    R语言merge函数全连接dataframe数据(Full (outer) join).merge函数进行全连接必须将参数all设置为true(all=TRUE).默认merge函数通过公共列名合并数 ...

  4. pandas获取dataframe数据列的数据类型、获取dataframe每类数据类型数据列的个数、使用select_dtypes函数、include参数以及exclude参数按照数据类型筛选数据

    pandas获取dataframe数据列的数据类型.获取dataframe每类数据类型数据列的个数.使用select_dtypes函数.include参数以及exclude参数按照数据类型筛选数据 目 ...

  5. c语言函数参数类型检查,内联函数在编译时是否做参数类型检查?

    先说宏和函数的区别: 1. 宏做的是简单的字符串替换(注意是字符串的替换,不是其他类型参数的替换),而函数的参数的传递,参数是有数据类型的,可以是各种各样的类型. 2. 宏的参数替换是不经计算而直接处 ...

  6. Python中函数的参数传递与可变长参数

    1.Python中也有像C++一样的默认缺省函数 1 def foo(text,num=0): 2 print text,num 3 4 foo("asd") #asd 0 5 f ...

  7. python def函数报错详解_【python】详解python函数定义 def()与参数args、可变参数*args、关键参数**args使用实例...

    Python内置了很多函数,可以直接调用.Python内置的函数可以通过官方文档查看.也可以通过help()查看帮助信息.函数名是指向函数对象的引用,把函数名赋给变量,相当于给函数起了别名. 1. 定 ...

  8. Swift 1.1语言函数参数的特殊情况本地参数名外部参数名

    Swift 1.1语言函数参数的特殊情况本地参数名外部参数名 7.4  函数参数的特殊情况 声明定义有参函数时,为函数的每一个参数都定义了参数名称.根据参数名定义的形式不同,函数参数包括本地参数和外部 ...

  9. python函数中可变参数的传递方式是_Python中函数的参数传递与可变长参数

    1.Python中也有像C++一样的默认缺省函数 1 def foo(text,num=0):2 printtext,num3 4 foo("asd") #asd 0 5 foo( ...

最新文章

  1. MIT给人工智能“泼冷水”:AI创造性目前有限
  2. android鼾声分析,鼾声分析器
  3. 开源微服务运行时 Dapr 发布 1.0 版本
  4. css3实现超出文本指定行数(指定文本长度)用省略号代替
  5. 设置图例字体_R高级画图(0903)关于字体、溪流图、ggplot2主题等设置 (tidyTuesday)...
  6. 光纤测试仪为什么使用单芯法为光纤损耗测量
  7. shell脚本参数中有空格
  8. 为了给女朋友独特的七夕惊喜,我学会了人像美肤算法!
  9. nginx 多php项目配置文件,nginx 配置文件配置多个站点
  10. 关于Unicode字符集
  11. PAIP VCF通讯录的乱码以及导入导出
  12. Scene Graph Generation by Iterative Message Passing
  13. 网络科技行业再续签 易趋云助力搭建高效项目管理云平台
  14. 苹果Mac 软件出现意外退出解决方法
  15. 药剂学(专)-形考作业(一)答案
  16. jpi多表联查_使用Mybatis进行多表联查操作
  17. 虚拟化桌面设备输入法
  18. 推荐几本纳米级光刻机书籍
  19. Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included
  20. HDU-4037-线段树-区间开根号

热门文章

  1. rstudio 管道符号_R中的管道指南
  2. 1869. 哪种连续子字符串更长
  3. 怎么注销笔记本icloud_如何在笔记本电脑或台式机的Web浏览器中在线查看Apple iCloud照片
  4. chrome扩展程序_如何创建Chrome扩展程序
  5. 肉体之爱的解释圣经_可以解释的AI简介,以及我们为什么需要它
  6. 多维空间可视化_使用GeoPandas进行空间可视化
  7. 全栈入门_启动数据栈入门包(2020)
  8. python:动态参数*args
  9. usaco-sprime-superprime-pass
  10. Overlay Surfaces (覆盖表面)