SocketOptionLevel 枚举

定义

public enum class SocketOptionLevel
public enum SocketOptionLevel
type SocketOptionLevel = 
Public Enum SocketOptionLevel
继承
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.SetSocketOptionSocket.GetSocketOption方法的套接字选项级别。 SocketOptionName 枚举值按 SocketOptionLevel.

注意 若要在 Windows XP 上使用 IPv6,请安装适用于 Windows XP 的高级网络包。

适用于

另请参阅