Show / Hide Table of Contents

Class PortRange

Class to manage port allocation for Rtp Ports. Ports are always even, because due Rtp data and control ports are always with data on even port and control (if any) on data_port + 1

There are two operation modes:

  • The sequential mode which hands out all ports within the assigned range and wraps around if the last port was assigned
  • The shuffled mode: Ports are handed out evenly distributed within the assigned port range.
Inheritance
System.Object
PortRange
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: SIPSorcery.Sys
Assembly: SIPSorcery.dll
Syntax
public class PortRange

Constructors

| Improve this Doc View Source

PortRange(Int32, Int32, Boolean, Nullable<Int32>)

Initializes a new PortRange.

Declaration
public PortRange(int startPort, int endPort, bool shuffle = false, int? randomSeed = null)
Parameters
Type Name Description
System.Int32 startPort

Inclusive, lowest port within this portrange. must be an even number

System.Int32 endPort

Inclusive, highest port within this portrange.

System.Boolean shuffle

optional, if set, the ports are assigned in a pseudorandom order.

System.Nullable<System.Int32> randomSeed

optional, the seed for the pseudorandom order.

Exceptions
Type Condition
System.ArgumentException

Fields

| Improve this Doc View Source

EndPort

Declaration
public readonly int EndPort
Field Value
Type Description
System.Int32
| Improve this Doc View Source

StartPort

Declaration
public readonly int StartPort
Field Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

GetNextPort()

Calculates the next port which should be tried. No guarantee is made, that the returned port can also be bound to; actual check is still needed. Caller of this method should try to bind to the socket and if not successful, try again for x times before giving up.

This method is thread-safe

Declaration
public virtual int GetNextPort()
Returns
Type Description
System.Int32

port from the portrange

Extension Methods

JSONWriter.ToJson(Object)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX