AcceptList Property
Collapse the table of content
Expand the table of content

SocketPermission.AcceptList Property

Gets a list of EndpointPermission instances that identifies the endpoints that can be accepted under this permission instance.

Namespace:  System.Net
Assembly:  System (in System.dll)

Public ReadOnly Property AcceptList As IEnumerator

Property Value

Type: System.Collections.IEnumerator
An instance that implements the IEnumerator interface that contains EndpointPermission instances.

The following example uses the AcceptList property to return a list of endpoints to which accept privileges are granted.

' Creates a SocketPermission restricting access to and from all URIs.
Dim mySocketPermission1 As New SocketPermission(PermissionState.None)

' The socket to which this permission will apply will allow connections from
mySocketPermission1.AddPermission(NetworkAccess.Accept, TransportType.Tcp, "", 11000)

' Creates a SocketPermission which will allow the target Socket to connect with
Dim mySocketPermission2 As New SocketPermission(NetworkAccess.Connect, TransportType.Tcp, "", 11002)

' Creates a SocketPermission from the union of two SocketPermissions.
Dim mySocketPermissionUnion As SocketPermission = CType(mySocketPermission1.Union(mySocketPermission2), SocketPermission)

' Checks to see if the union was successfully created by using the IsSubsetOf method.
If mySocketPermission1.IsSubsetOf(mySocketPermissionUnion) And mySocketPermission2.IsSubsetOf(mySocketPermissionUnion) Then
   Console.WriteLine("This union contains permissions from both mySocketPermission1 and mySocketPermission2")

   ' Prints the allowable accept URIs to the console.
   Console.WriteLine("This union accepts connections on :")

   Dim myEnumerator As IEnumerator = mySocketPermissionUnion.AcceptList
   While myEnumerator.MoveNext()
      Console.WriteLine(CType(myEnumerator.Current, EndpointPermission).ToString())
   End While

   Console.WriteLine("This union establishes connections on : ")

   ' Prints the allowable connect URIs to the console.
   Console.WriteLine("This union permits connections to :")

   myEnumerator = mySocketPermissionUnion.ConnectList
   While myEnumerator.MoveNext()
      Console.WriteLine(CType(myEnumerator.Current, EndpointPermission).ToString())
   End While
End If 

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2015 Microsoft