SocketOptionName 列舉

定義

定義組態選項名稱。Defines configuration option names.

public enum class SocketOptionName
public enum SocketOptionName
type SocketOptionName = 
Public Enum SocketOptionName
繼承
SocketOptionName

欄位

AcceptConnection 2

通訊端正在接聽。The socket is listening.

AddMembership 12

加入 IP 群組成員資格。Add an IP group membership.

AddSourceMembership 15

聯結來源群組。Join a source group.

BlockSource 17

封鎖來自來源的資料。Block data from a source.

Broadcast 32

允許在通訊端上傳送廣播訊息。Permit sending broadcast messages on the socket.

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 20

設定或取得 UDP 總和檢查碼涵蓋範圍。Set or get the UDP checksum coverage.

Debug 1

記錄偵錯資訊。Record debugging information.

DontFragment 14

不要將 IP 資料包分成片段。Do not fragment IP datagrams.

DontLinger -129

立即關閉通訊端。Close the socket gracefully without lingering.

DontRoute 16

不進行路由,直接將封包傳送至介面位址。Do not route; send the packet directly to the interface addresses.

DropMembership 13

捨棄 IP 群組成員資格。Drop an IP group membership.

DropSourceMembership 16

捨棄來源群組。Drop a source group.

Error 4103

取得錯誤狀態並清除。Gets the error status and clear.

ExclusiveAddressUse -5

啟用將繫結至獨佔存取的通訊端。Enables a socket to be bound for exclusive access.

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 2

表示應用程式將提供輸出資料包的 IP 標頭。Indicates that the application provides the IP header for outgoing datagrams.

HopLimit 21

指定網際網路通訊協定第 6 版 (IPv6) 封包的最大路由器躍點數。Specifies the maximum number of router hops for an Internet Protocol version 6 (IPv6) packet. 這與網際網路通訊協定第 4 版的存留時間 (TTL) 類似。This is similar to Time to Live (TTL) for Internet Protocol version 4.

IPOptions 1

指定要插入輸出資料包的 IP 選項。Specifies the IP options to be inserted into outgoing datagrams.

IPProtectionLevel 23

啟用 IPv6 通訊端至指定範圍的限制,例如具有相同連結本機或網站本機前置詞的位址。Enables restriction of a IPv6 socket to a specified scope, such as addresses with the same link local or site local prefix. 此通訊端選項可讓應用程式在 IPv6 通訊端上放置存取限制。This socket option enables applications to place access restrictions on IPv6 sockets. 這類限制可以讓應用程式在私人 LAN 上執行,簡便又穩當地強化應用程式對外部攻擊的抵禦。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 4

設定 IP 標頭的存留時間欄位。Set the IP header Time-to-Live field.

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 位址的封包。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 8

使用 Keep-Alive。Use keep-alives.

Linger 128

如果有未傳送的資料,則延遲關閉。Linger on close if unsent data is present.

MaxConnections 2147483647

不支援,如果使用則會擲回 SocketExceptionNot supported; will throw a SocketException if used.

MulticastInterface 9

設定用於輸出多點傳送封包的介面。Set the interface for outgoing multicast packets.

MulticastLoopback 11

IP 多點傳送回送。An IP multicast loopback.

MulticastTimeToLive 10

IP 多點傳送存留時間。An IP multicast Time to Live.

NoChecksum 1

在總和檢查碼設定為零的情況下傳送 UDP 資料包。Send UDP datagrams with checksum set to zero.

NoDelay 1

停用用於傳送聯合的 Nagle 演算法。Disables the Nagle algorithm for send coalescing.

OutOfBandInline 256

在一般資料流中接收頻外 (Out-of-Band) 資料。Receives out-of-band data in the normal data stream.

PacketInformation 19

傳回所接收封包的相關資訊。Return information about received packets.

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 4100

指定指定 Receive 作業的下限標準。Specifies the low water mark for Receive operations.

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 4

允許要繫結至已使用中位址的通訊端。Allows the socket to be bound to an address that is already in use.

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 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 4099

指定指定 Send 作業的下限標準。Specifies the low water mark for Send operations.

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 17

在傳送另一個保持連線探查之前,TCP 連線將等候保持連線回應的秒數。The number of seconds a TCP connection will wait for a keepalive response before sending another keepalive probe.

TcpKeepAliveRetryCount 16

在終止連線之前,會傳送的 TCP 保持連線探查數目。The number of TCP keep alive probes that will be sent before the connection is terminated.

TcpKeepAliveTime 3

在將保持連線探查傳送至遠端之前,TCP 連線將保持運作/閒置的秒數。The number of seconds a TCP connection will remain alive/idle before keepalive probes are sent to the remote.

Type 4104

取得通訊端類型。Gets the socket type.

TypeOfService 3

變更服務欄位的 IP 標頭類型。Change the IP header type of the service field.

UnblockSource 18

取消封鎖先前所封鎖的來源。Unblock a previously blocked source.

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 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 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)

備註

SocketOptionName列舉會定義每個設定選項的名稱 SocketThe SocketOptionName enumeration defines the name of each Socket configuration option. 您可以使用方法來設定通訊端 Socket.SetSocketOptionSockets can be configured with the Socket.SetSocketOption method.

適用於

另請參閱