SocketOptionLevel 枚举

定义

public enum class SocketOptionLevel
public enum SocketOptionLevel
type SocketOptionLevel = 
Public Enum SocketOptionLevel
继承
SocketOptionLevel

字段

IP 0

Socket 选项仅适用于 IP 套接字。Socket options apply only to IP sockets.

IPv6 41

Socket 选项仅适用于 IPv6 套接字。Socket options apply only to IPv6 sockets.

Socket 65535

Socket 选项适用于所有套接字。Socket options apply to all sockets.

Tcp 6

Socket 选项仅适用于 TCP 套接字。Socket options apply only to TCP sockets.

Udp 17

Socket 选项仅适用于 UDP 套接字。Socket options apply only to UDP sockets.

示例

下面的示例使用此枚举来设置套接字选项。The following 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.SetSocketOption给和Socket.GetSocketOption方法的套接字选项级别。 SocketOptionLevelThe SocketOptionLevel enumeration defines the socket option levels that can be passed to the Socket.SetSocketOption and Socket.GetSocketOption methods. SocketOptionName枚举值按SocketOptionLevel分组。SocketOptionName enumerated values are grouped by SocketOptionLevel.

注意若要在 Windows XP 上使用 IPv6, 请安装适用于 Windows XP 的高级网络包。Note To use IPv6 on Windows XP, install Advance Networking Pack for Windows XP.

适用于

另请参阅