PortFinderFindAvailablePort Method |
Attempts to find a contiguous range of free local ports.
Namespace: StreamCoders.HelpersAssembly: 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
)
Public Shared Function FindAvailablePort (
protocolType As ProtocolType,
lowerBound As Integer,
upperBound As Integer,
parity As NumberParity,
Optional lookahead As Integer = 0
) As Integer
public:
static int FindAvailablePort(
ProtocolType protocolType,
int lowerBound,
int upperBound,
NumberParity parity,
int lookahead = 0
)
static member FindAvailablePort :
protocolType : ProtocolType *
lowerBound : int *
upperBound : int *
parity : NumberParity *
?lookahead : int
(* Defaults:
let _lookahead = defaultArg lookahead 0
*)
-> int
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:
Int32Returns a port number that matches the critera, otherwise -1.
Remarks
The method will attempt to find a port range within 20 iterations.
See Also