SocketOptionLevel 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
定義 SetSocketOption(SocketOptionLevel, SocketOptionName, Int32) 和 GetSocketOption(SocketOptionLevel, SocketOptionName) 方法的通訊端 (Socket) 選項層級。
public enum class SocketOptionLevel
public enum SocketOptionLevel
type SocketOptionLevel =
Public Enum SocketOptionLevel
- 繼承
欄位
IP | 0 | Socket 選項只套用至 IP 通訊端。 |
IPv6 | 41 | Socket 選項只適用於 IPv6 通訊端。 |
Socket | 65535 | Socket 選項會套用至所有通訊端。 |
Tcp | 6 | Socket 選項只套用至 TCP 通訊端。 |
Udp | 17 | Socket 選項只套用至 UDP 通訊端。 |
範例
下列範例會使用此列舉來設定通訊端選項。
// 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)
備註
列舉 SocketOptionLevel 會定義可傳遞至 和 Socket.GetSocketOption 方法的 Socket.SetSocketOption 通訊端選項層級。 SocketOptionName 列舉值會依 SocketOptionLevel 分組。
注意 若要在 Windows XP 上使用 IPv6,請安裝適用于 Windows XP 的進階網路套件。