public sealed class SocketPermissionAttribute : CodeAccessSecurityAttribute
Object
Attribute
SecurityAttribute
CodeAccessSecurityAttribute
SocketPermissionAttribute
System
Networking
Used to declaratively specify security actions to control socket connections.
The properties of a SocketPermissionAttribute are required to have non-null values. Once set, the values of the properties cannot be changed.[Note: The details of a socket connection are specified using the properties of the current instance. For example, to secure a socket connection to port 80, set the System.Net.SocketPermissionAttribute.Port property equal to "80".
The security information declared by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. Security attributes are used for declarative security only. For imperative security, use the corresponding permission class, SocketPermission .
The allowable SocketPermissionAttribute targets are determined by the SecurityAction passed to the constructor.
]
AttributeUsageAttribute(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple=true, Inherited=false)
System.Net Namespace
SocketPermissionAttribute Constructors
SocketPermissionAttribute Constructor
SocketPermissionAttribute Methods
SocketPermissionAttribute.CreatePermission Method
SocketPermissionAttribute Properties
SocketPermissionAttribute.Access Property
SocketPermissionAttribute.Host Property
SocketPermissionAttribute.Port Property
SocketPermissionAttribute.Transport Property
public SocketPermissionAttribute(SecurityAction action);
Constructs and initializes a new instance of the SocketPermissionAttribute class with the specified SecurityAction value.
- action
- A SecurityAction value.
System.Net.SocketPermissionAttribute Class, System.Net Namespace
public override IPermission CreatePermission();
Returns a SocketPermission that contains the security information of the current instance.
A SocketPermission object with the security information of the current instance.
Exception Type Condition ArgumentException One or more of the current instance's System.Net.SocketPermissionAttribute.Access, System.Net.SocketPermissionAttribute.Host, System.Net.SocketPermissionAttribute.Transport or System.Net.SocketPermissionAttribute.Port properties is null
.
[Note: This method overrides System.Security.Permissions.SecurityAttribute.CreatePermission.Applications typically do not call this method; it is intended for use by the system.
The security information described by a security attribute is stored in the metadata of the attribute target, and is accessed by the system at run-time. The system uses the object returned by this method to convert the security information of the current instance into the form stored in metadata.
]
System.Net.SocketPermissionAttribute Class, System.Net Namespace
public string Access { get; set; }
Gets or sets the network access method specified by the current instance.
A String containing a network access method allowed by the current instance. Valid values are "Accept" and "Connect".
Exception Type Condition ArgumentException System.Net.SocketPermissionAttribute.Access is being set and is not null
.
This property is write-once. Once this property has been set to a non-null value, attempts to set this property to new value cause a ArgumentException .Valid values for this property correspond to NetworkAccess enumeration values.
System.Net.SocketPermissionAttribute Class, System.Net Namespace
public string Host { get; set; }
Gets or sets the DNS host name or IP address specified by the current instance.
A String containing a DNS host name or IP address.
Exception Type Condition ArgumentException System.Net.SocketPermissionAttribute.Host is being set and is not null
.
This property is write-once. Once this property has been set to a non-null value, attempts to set this property to new value cause a ArgumentException.
System.Net.SocketPermissionAttribute Class, System.Net Namespace
public string Port { get; set; }
Gets or sets the port specified by the current instance.
A String containing a port number, or "All" or -1 to indicate all ports.
Exception Type Condition ArgumentException System.Net.SocketPermissionAttribute.Port is being set and is not null
.
This property is write-once. Once this property has been set to a non-null value, attempts to set this property to new value cause a ArgumentException .
System.Net.SocketPermissionAttribute Class, System.Net Namespace
public string Transport { get; set; }
Gets or sets the transport type specified by the current instance.
A String containing the transport type associated with the current instance. Valid values are "All", "Connectionless", "ConnectionOriented", "Tcp", and "Udp".
Exception Type Condition ArgumentException System.Net.SocketPermissionAttribute.Transport is being set and is not null
.
This property is write-once. Once this property has been set to a non-null value, attempts to set this property to new value cause a ArgumentException .[Note: Valid values for this property correspond to TransportType enumeration values.]
System.Net.SocketPermissionAttribute Class, System.Net Namespace