SocketOptionName SocketOptionName SocketOptionName SocketOptionName Enum

定义

定义配置选项名称。Defines configuration option names.

public enum class SocketOptionName
public enum SocketOptionName
type SocketOptionName = 
Public Enum SocketOptionName
继承
SocketOptionNameSocketOptionNameSocketOptionNameSocketOptionName

字段

AcceptConnection AcceptConnection AcceptConnection AcceptConnection 2

套接字正在侦听。The socket is listening.

AddMembership AddMembership AddMembership AddMembership 12

添加一个 IP 组成员。Add an IP group membership.

AddSourceMembership AddSourceMembership AddSourceMembership AddSourceMembership 15

联接源组。Join a source group.

BlockSource BlockSource BlockSource BlockSource 17

阻止源中的数据。Block data from a source.

Broadcast Broadcast Broadcast Broadcast 32

允许在套接字上发送广播消息。Permit sending broadcast messages on the socket.

BsdUrgent BsdUrgent BsdUrgent BsdUrgent 2

使用 RFC-1222 中定义的紧急数据。Use urgent data as defined in RFC-1222. 此选项只能设置一次,而且设置以后就不能关闭。This option can be set only once; after it is set, it cannot be turned off.

ChecksumCoverage ChecksumCoverage ChecksumCoverage ChecksumCoverage 20

设置或获取 UDP 校验和覆盖。Set or get the UDP checksum coverage.

Debug Debug Debug Debug 1

记录调试信息。Record debugging information.

DontFragment DontFragment DontFragment DontFragment 14

不对 IP 数据报进行分段。Do not fragment IP datagrams.

DontLinger DontLinger DontLinger DontLinger -129

完全关闭套接字,不做逗留。Close the socket gracefully without lingering.

DontRoute DontRoute DontRoute DontRoute 16

不路由,将数据包直接发送到接口地址。Do not route; send the packet directly to the interface addresses.

DropMembership DropMembership DropMembership DropMembership 13

放置一个 IP 组成员。Drop an IP group membership.

DropSourceMembership DropSourceMembership DropSourceMembership DropSourceMembership 16

放置一个源组。Drop a source group.

Error Error Error Error 4103

获取错误状态并清除。Gets the error status and clear.

ExclusiveAddressUse ExclusiveAddressUse ExclusiveAddressUse ExclusiveAddressUse -5

使套接字能够为独占访问进行绑定。Enables a socket to be bound for exclusive access.

Expedited Expedited Expedited Expedited 2

使用 RFC-1222 中定义的加急数据。Use expedited data as defined in RFC-1222. 此选项只能设置一次,而且设置以后就不能关闭。This option can be set only once; after it is set, it cannot be turned off.

HeaderIncluded HeaderIncluded HeaderIncluded HeaderIncluded 2

指示应用程序为输出数据报提供 IP 头。Indicates that the application provides the IP header for outgoing datagrams.

HopLimit HopLimit HopLimit HopLimit 21

指定 Internet 协议版本 6 (IPv6) 数据包的最大路由器跃点数目。Specifies the maximum number of router hops for an Internet Protocol version 6 (IPv6) packet. 这类似于 Internet 协议版本 4 的生存时间 (TTL)。This is similar to Time to Live (TTL) for Internet Protocol version 4.

IPOptions IPOptions IPOptions IPOptions 1

指定要插入到输出数据报中的 IP 选项。Specifies the IP options to be inserted into outgoing datagrams.

IPProtectionLevel IPProtectionLevel IPProtectionLevel IPProtectionLevel 23

可用于将 IPv6 套接字限制为一个指定范围,例如限制为具有相同的链接本地或站点本地前缀的地址。利用此套接字选项,应用程序可以对 IPv6 套接字设置访问限制。Enables restriction of a IPv6 socket to a specified scope, such as addresses with the same link local or site local prefix.This socket option enables applications to place access restrictions on IPv6 sockets. 通过应用此类限制,可让在专用局域网上运行的应用程序能够通过简单的方式很好地增强自身的安全性,以便防范外部攻击。Such restrictions enable an application running on a private LAN to simply and robustly harden itself against external attacks. 此套接字选项可以扩大或缩小侦听套接字的范围,从而使得公共用户和私人用户可以在适当情况下对站点进行无限制的访问,或者可以根据需要对同一站点进行有限制的访问。This socket option widens or narrows the scope of a listening socket, enabling unrestricted access from public and private users when appropriate, or restricting access only to the same site, as required. 此套接字选项具有 IPProtectionLevel 枚举中指定的已定义保护级别。This socket option has defined protection levels specified in the IPProtectionLevel enumeration.

IpTimeToLive IpTimeToLive IpTimeToLive IpTimeToLive 4

设置 IP 头生存时间字段。Set the IP header Time-to-Live field.

IPv6Only IPv6Only IPv6Only IPv6Only 27

指示为 AF_INET6 地址族创建的套接字是否仅适用于 IPv6 通信。Indicates if a socket created for the AF_INET6 address family is restricted to IPv6 communications only. 为 AF_INET6 地址族创建的套接字可用于 IPv6 和 IPv4 通信。Sockets created for the AF_INET6 address family may be used for both IPv6 and IPv4 communications. 一些应用程序可能需要将为 AF_INET6 地址族创建的套接字限制为仅用于 IPv6 通信。Some applications may want to restrict their use of a socket created for the AF_INET6 address family to IPv6 communications only. 当此值不为零(Windows 上的默认值)时,为 AF_INET6 地址族创建的套接字只可用于发送和接收 IPv6 数据包。When this value is non-zero (the default on Windows), a socket created for the AF_INET6 address family can be used to send and receive IPv6 packets only. 当此值为零时,为 AF_INET6 地址族创建的套接字可用于向 IPv6 地址或 IPv4 地址发送数据包以及从 IPv6 地址或 IPv4 地址接收数据包。When this value is zero, a socket created for the AF_INET6 address family can be used to send and receive packets to and from an IPv6 address or an IPv4 address. 请注意,需要使用 IPv4 映射地址才能与 IPv4 地址进行交互。Note that the ability to interact with an IPv4 address requires the use of IPv4 mapped addresses. Windows Vista 或更高版本上支持此套接字选项。This socket option is supported on Windows Vista or later.

KeepAlive KeepAlive KeepAlive KeepAlive 8

使用 keep-alive。Use keep-alives.

Linger Linger Linger Linger 128

如果存在未发送的数据,则在关闭时逗留。Linger on close if unsent data is present.

MaxConnections MaxConnections MaxConnections MaxConnections 2147483647

不受支持;如果使用,将引发 SocketExceptionNot supported; will throw a SocketException if used.

MulticastInterface MulticastInterface MulticastInterface MulticastInterface 9

为输出的多路广播数据包设置接口。Set the interface for outgoing multicast packets.

MulticastLoopback MulticastLoopback MulticastLoopback MulticastLoopback 11

IP 多路广播环回。An IP multicast loopback.

MulticastTimeToLive MulticastTimeToLive MulticastTimeToLive MulticastTimeToLive 10

IP 多路广播生存时间。An IP multicast Time to Live.

NoChecksum NoChecksum NoChecksum NoChecksum 1

发送校验和设置为零的 UDP 数据报。Send UDP datagrams with checksum set to zero.

NoDelay NoDelay NoDelay NoDelay 1

为发送合并禁用 Nagle 算法。Disables the Nagle algorithm for send coalescing.

OutOfBandInline OutOfBandInline OutOfBandInline OutOfBandInline 256

接收正常数据流中的带外数据。Receives out-of-band data in the normal data stream.

PacketInformation PacketInformation PacketInformation PacketInformation 19

返回有关接收到的数据包的信息。Return information about received packets.

ReceiveBuffer ReceiveBuffer ReceiveBuffer ReceiveBuffer 4098

指定为接收保留的每个套接字缓冲区空间的总量。Specifies the total per-socket buffer space reserved for receives. 这与最大消息大小或 TCP 窗口的大小无关。This is unrelated to the maximum message size or the size of a TCP window.

ReceiveLowWater ReceiveLowWater ReceiveLowWater ReceiveLowWater 4100

Receive 操作指定低水印。Specifies the low water mark for Receive operations.

ReceiveTimeout ReceiveTimeout ReceiveTimeout ReceiveTimeout 4102

接收超时。此选项只适用于同步方法,它对异步方法(如 BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) 方法)无效。Receive a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) method.

ReuseAddress ReuseAddress ReuseAddress ReuseAddress 4

允许将套接字绑定到已在使用中的地址。Allows the socket to be bound to an address that is already in use.

ReuseUnicastPort ReuseUnicastPort ReuseUnicastPort ReuseUnicastPort 12295

指示系统应延迟出站连接的临时端口分配。Indicates that the system should defer ephemeral port allocation for outbound connections. 这等效于使用 Winsock2 SO_REUSE_UNICASTPORT 套接字选项。This is equivalent to using the Winsock2 SO_REUSE_UNICASTPORT socket option.

SendBuffer SendBuffer SendBuffer SendBuffer 4097

指定为发送保留的每个套接字缓冲区空间的总量。Specifies the total per-socket buffer space reserved for sends. 这与最大消息大小或 TCP 窗口的大小无关。This is unrelated to the maximum message size or the size of a TCP window.

SendLowWater SendLowWater SendLowWater SendLowWater 4099

Send 操作指定低水印。Specifies the low water mark for Send operations.

SendTimeout SendTimeout SendTimeout SendTimeout 4101

发送超时。此选项只适用于同步方法,它对异步方法(如 BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) 方法)无效。Send a time-out. This option applies only to synchronous methods; it has no effect on asynchronous methods such as the BeginSend(Byte[], Int32, Int32, SocketFlags, AsyncCallback, Object) method.

TcpKeepAliveInterval TcpKeepAliveInterval TcpKeepAliveInterval TcpKeepAliveInterval 17

在发送另一个 keepalive 探测之前,一个 TCP 连接等待某 keepalive 响应的秒数。The number of seconds a TCP connection will wait for a keepalive response before sending another keepalive probe.

TcpKeepAliveRetryCount TcpKeepAliveRetryCount TcpKeepAliveRetryCount TcpKeepAliveRetryCount 16

在终止连接之前将发送的 TCP keepalive 探测数。The number of TCP keep alive probes that will be sent before the connection is terminated.

TcpKeepAliveTime TcpKeepAliveTime TcpKeepAliveTime TcpKeepAliveTime 3

将 keepalive 探测发送到远程设备之前,一个 TCP 连接将保持活动/空闲的秒数。The number of seconds a TCP connection will remain alive/idle before keepalive probes are sent to the remote.

Type Type Type Type 4104

获取套接字类型。Gets the socket type.

TypeOfService TypeOfService TypeOfService TypeOfService 3

更改服务字段的 IP 头类型。Change the IP header type of the service field.

UnblockSource UnblockSource UnblockSource UnblockSource 18

取消阻止先前被阻止的源。Unblock a previously blocked source.

UpdateAcceptContext UpdateAcceptContext UpdateAcceptContext UpdateAcceptContext 28683

使用现有套接字的属性更新已接受套接字的属性。Updates an accepted socket's properties by using those of an existing socket. 这等效于使用 Winsock2 SO_UPDATE_ACCEPT_CONTEXT 套接字选项,并且仅在面向连接的套接字上受支持。This is equivalent to using the Winsock2 SO_UPDATE_ACCEPT_CONTEXT socket option and is supported only on connection-oriented sockets.

UpdateConnectContext UpdateConnectContext UpdateConnectContext UpdateConnectContext 28688

使用现有套接字的属性更新已连接套接字的属性。Updates a connected socket's properties by using those of an existing socket. 这等效于使用 Winsock2 SO_UPDATE_CONNECT_CONTEXT 套接字选项,并且仅在面向连接的套接字上受支持。This is equivalent to using the Winsock2 SO_UPDATE_CONNECT_CONTEXT socket option and is supported only on connection-oriented sockets.

UseLoopback UseLoopback UseLoopback UseLoopback 64

可能时避开硬件。Bypass hardware when possible.

示例

下面的代码示例使用此枚举来设置套接字选项。The following code example uses this enumeration to set socket options.

// Specifies that send operations will time-out 
// if confirmation is not received within 1000 milliseconds.
s->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::SendTimeout, 1000 );

// Specifies that the Socket will linger for 10 seconds after Close is called.
LingerOption^ lingerOption = gcnew LingerOption( true,10 );

s->SetSocketOption( SocketOptionLevel::Socket, SocketOptionName::Linger, lingerOption );
// Send operations will time-out if confirmation 
// is not received within 1000 milliseconds.
s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1000);

// The socket will linger for 10 seconds after Socket.Close is called.
LingerOption lingerOption = new LingerOption (true, 10);

s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.Linger, lingerOption);

'Send operations will time-out if confirmation is 
' not received within 1000 milliseconds.
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 1000)

' The socket will linger for 10 seconds after Socket.Close is called.
Dim lingerOption As New LingerOption(True, 10)
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, lingerOption)

注解

枚举定义每个Socket配置选项的名称。 SocketOptionNameThe SocketOptionName enumeration defines the name of each Socket configuration option. 可以用Socket.SetSocketOption方法配置套接字。Sockets can be configured with the Socket.SetSocketOption method.

适用于

另请参阅