<PackageReference Include="System.Security.Permissions" Version="9.0.3" />

SocketPermission

Controls rights to make or accept connections on a transport address.
public const int AllPorts = -1

Defines a constant that represents all ports.

public IEnumerator AcceptList { get; }

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

public IEnumerator ConnectList { get; }

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

public SocketPermission(NetworkAccess access, TransportType transport, string hostName, int portNumber)

Initializes a new instance of the SocketPermission class for the given transport address with the specified permission.

Initializes a new instance of the SocketPermission class that allows unrestricted access to the Socket or disallows access to the Socket.

public void AddPermission(NetworkAccess access, TransportType transport, string hostName, int portNumber)

Adds a permission to the set of permissions for a transport address.

public bool IsUnrestricted()

Checks the overall permission state of the object.