CIRCDCC.getNextPort Member

Syntax

object.getNextPort();

Returns

Remarks

See Also

Source Code

function dcc_getnextport()
{
var portList = this.listenPorts;
var newPort = this._lastPort;
for (var i = 0; i < portList.length; i++)
{
var m = portList[i].match(/^(\d+)(?:-(\d+))?$/);
if (m)
{
if (!newPort)
{
// We dodn't have any previous port, so just take the first we
// find.
return this._lastPort = Number(m[1]);
}
else if (arrayHasElementAt(m, 2))
{
// Port range. Anything before range, or in [exl. last value]
// is ok. Make sure first value is lowest value returned.
if (newPort < m[2])
return this._lastPort = Math.max(newPort + 1, Number(m[1]));
}
else
{
// Single port.
if (newPort < m[1])
return this._lastPort = Number(m[1]);
}
}
}
// No ports found, and no last port --> use OS.
if (newPort == null)
return -1;
// Didn't find anything... d'oh. Need to start from the begining again.
this._lastPort = null;
return this.getNextPort();
}