private byte GetNextConnectionId()
{
lock (_lastConnectionLock)
{
byte saveLast = _lastConnectionId;
while (_tcpConnections.IsLocalOpenConnection(++_lastConnectionId))
{
if (_lastConnectionId != saveLast)
{
throw new ConnectionException("Cannot get next connection id, all connections in use");
}
}
}
Logger.Debug("Found next connection id " + _lastConnectionId);
return _lastConnectionId;
}