Export (0) Print
Expand All

SocketOptionLevel Enumeration

Defines socket option levels for the Socket.SetSocketOption and Socket.GetSocketOption methods.

[Visual Basic]
<Serializable>
Public Enum SocketOptionLevel
[C#]
[Serializable]
public enum SocketOptionLevel
[C++]
[Serializable]
__value public enum SocketOptionLevel
[JScript]
public
   Serializable
enum SocketOptionLevel

Remarks

The SocketOptionLevel enumeration defines the socket option levels that can be passed to the Socket.SetSocketOption and Socket.GetSocketOption methods. SocketOptionName enumerated values are grouped by SocketOptionLevel.

Members

Member name Description
IP

Supported by the .NET Compact Framework.

Socket options apply only to IP sockets.
IPv6
Socket

Supported by the .NET Compact Framework.

Socket options apply to all sockets.
Tcp

Supported by the .NET Compact Framework.

Socket options apply only to TCP sockets.
Udp

Supported by the .NET Compact Framework.

Socket options apply only to UDP sockets.

Example

[Visual Basic, C#, C++] The following example uses this enumeration to set socket options.

[Visual Basic] 
'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)


[C#] 
// 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);


[C++] 
// 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 = new LingerOption(true, 10);
s->SetSocketOption(SocketOptionLevel::Socket, SocketOptionName::Linger, lingerOption);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Net.Sockets

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System (in System.dll)

See Also

System.Net.Sockets Namespace | Socket | SocketOptionName

Show:
© 2015 Microsoft