Click or drag to resize
PortFinderFindAvailablePort Method
Attempts to find a contiguous range of free local ports.

Namespace: StreamCoders.Helpers
Assembly: MediaBase (in MediaBase.dll) Version: 2.0.5.0 (2.0.5.0)
Syntax
public static int FindAvailablePort(
	ProtocolType protocolType,
	int lowerBound,
	int upperBound,
	NumberParity parity,
	int lookahead = 0
)

Parameters

protocolType
Type: System.Net.SocketsProtocolType
Choose either Udp or Tcp
lowerBound
Type: SystemInt32
Lower bound of port range to search.
upperBound
Type: SystemInt32
Upper bound of port range to search.
parity
Type: StreamCoders.HelpersNumberParity
The number parity
lookahead (Optional)
Type: SystemInt32
Number of ports to look ahead which must also be free.

Return Value

Type: Int32
Returns a port number that matches the critera, otherwise -1.
Remarks
The method will attempt to find a port range within 20 iterations.
See Also