setsockopt , getsoctopt 函数的Level 参数和 name 参数对应表!!!

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            /* Header is included with data */

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

#defineIPV6_MULTICAST_IF       /* 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.

 

格式太烂,请见谅!!!


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/404602.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Qt 调用MATLAB引擎混合编程

0、前言 C/C调用MATLAB有三个方式:调用dll文件、调用exe可执行程序和调用Engin引擎。 第一种方式利用MATLAB Coder 将MATLAB代码生成C/C代码和相关动态链接库,可以在没有MATLAB的电脑和设备上运行。 第二种方式利用MATLAB将MATLAB代码编译成exe可执行…

caja 原理 : 前端

作为前端开放的基础安全保证,caja 是目前比较合适的运行机制,包括前端运行环境以及后端编译环境,这次先整体介绍下 caja 在前端是如何屏蔽外部模块代码对整体应用的影响 (注意:官方文档较少,以下为自己理解…

[react] 请说说什么是useImperativeHandle?

[react] 请说说什么是useImperativeHandle? // useImperativeHandle 可以让你在使用 ref 时自定义暴露给父组件的实例值。 // useImperativeHandle 应当与 forwardRef 一起使用:import React, { useImperativeHandle, forwardRef } from react import {…

xcode3.2.6升级至4.0.2经验加教训总结(转)

首先,完美运行都项目直接在Xcode4.0.2中build可能会出现这样一个错误(人品好的自觉绕道):[BEROR]No architectures to compile for (ARCHSi386, VALID_ARCHS). 首先第一反应是打开工程的Build Settings,最基本的检测&a…

扩展欧几里德问题

我们先来看这个问题 求最大公约数的gcd(m,n)方法也可以如下定义: 如果m%n为0,那么gcd(m,n)的值为n. 否则,gcd(m,n)就是gcd(n,m%n) 编写一个递归的方法来求最大公约数。编写一个测试程序,计算gcd(24,16)和gcd(255,5) 我们先引入欧几…

步步为营:Asp.Net序列化Json格式的两种方法

过去我们使用JSON.net序列化一个对象,在asp.net3.5中已经集成了序列化对象为json的方法。 我们分别针对System.Runtime.Serialization.Json和System.Web.Script.Serialization两个命名空间下的不同方法进行序列化和反序列化。 System.Runtime.Serialization.Json (在…

[react] react中setState的第二个参数作用是什么呢?

[react] react中setState的第二个参数作用是什么呢? 第二个参数是一个callback函数,用于setState设置state的属性值成功之后的回调,此时调用this.state.property可以取到刚刚设置的最新的值 个人简介 我是歌谣,欢迎和大家一起…

Qt 调用VISA库通过SCPI程控仪器-以IT8906A电子负载为例

SCPI是一种可编程仪器的标准命令,可通过 GPIB, RS232, USB, LAN接口等控制仪器功能的编程语言。 SCPI 置于 IEEE 488.2 硬件部分的顶层。相同 SCPI 命令和参数控制着不同机器的相同功能。一般标准仪器都支持SCPI协议,如…

TCP控制字段标志:URG、ACK、PSH、RST、SYN、FIN

From: http://blog.csdn.net/wangfeng2500/article/details/7650062 在TCP层,有个FLAGS字段,这个字段有以下几个标识:SYN, FIN, ACK, PSH, RST, URG. 其中,对于我们日常的分析有用的就是前面的五个字段。 它们的含义是&#x…

Ubuntu 14.04 ThinkPad E431无线网卡驱动安装

Ubuntu 14.04下安装无线网卡驱动。 sudo apt-get install linux-headers-generic build-essential dkms sudo apt-get install linux-source sudo apt-get install --reinstall bcmwl-kernel-source sudo modprobe wl转载于:https://www.cnblogs.com/shoemaker/p/4800772.ht…

关于如何使用的MSCS(微软群集服务器)中的iSCSI Guest Initiators (客户机启动器)...

发布者:Dell-Terry Z 作者:戴尔公司 William U 嗨,大家好!过去的几周实在太激动人心了。第一届戴尔全球存储论坛(Dell Storage Forum)刚刚结束,我有一大堆的东西想跟大家分享,我想…

openssl版本信息和支持的命令

1、查看openssl版本 openssl version -a openssl version 可以看到版本信息和安装位置: 2、查看openssl支持的命令 openssl help Standard commands asn1parse ca ciphers cms crl crl2pkcs7 dgst …

[react] react中的setState是同步还是异步的呢?为什么state并不一定会同步更新?

[react] react中的setState是同步还是异步的呢?为什么state并不一定会同步更新? 由React控制的事件处理程序,以及生命周期函数调用setState不会同步更新state 。 React控制之外的事件中调用setState是同步更新的。比如原生js绑定的事件&…

还是FreeBSD

原文2005年4月13日写在MSN SPACE上 前几天做的FreeBSD服务器在使用过程中,流量大时会自动断线,提示如下一段话: no memory for rx buffer 一直找不出原因。今天把网卡换了,看明天是否还有错。转载于:https://blog.51cto.com/isgod…

python语法笔记(五)

1、python内存管理 (1)对象内存使用 &nsbp;&nsbp;&nsbp;&nsbp;在python中通过执行内建函数 id(obj) 可以获得对象obj在内存中的地址。在python中,整数和短小的字符,python都会缓存这些对象,以便重复使…

python实现手机号归属地相关信息查询

根据指定的手机号码,查询其归属地等相关信息,python实现: 手机号文件:test.txt 13693252552 13296629989 13640810839 15755106631 15119622732 13904446048 18874791953 13695658500 13695658547 15950179080 15573462779 15217…

[react] 请说说什么是useReducer?

[react] 请说说什么是useReducer? 基于 redux 思想实现简易数据控制流,useState 基于 reducer 实现 个人简介 我是歌谣,欢迎和大家一起交流前后端知识。放弃很容易, 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通关…

不被重视的基础,高效地使用ADO.net连接对象

很多初学者朋友在做项目时遇到过这样的问题,那就是在本地调试运行的程序正常,放到服务器上也是正常的,但是如果有了一些并发之后,就会发现页面会出现打不开的现像,其实大多数时候是因为Ado.net链接没有处理完善。当然对…

quick 中实现单例

直接贴代码 local danli nil local classname class("classname") function classname:getInstance() if danli nil then danli classname.new()     end return danli end return classname 使用 local duixiagn classname:getInstance()转载于:https://…

openssl创建CA并签发证书

一、创建私有CA根证书 1、创建CA目录 rootDESKTOP-JP3S3AN:/home/wsl/openssl_pro# mkdir -pv /etc/pki/CA/{private,certs,crl,newcerts} mkdir: created directory /etc/pki/CA mkdir: created directory /etc/pki/CA/private mkdir: created directory /etc/pki/CA/certs…