mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Octave: Change default port number and add custom port number to Preferences
This commit is contained in:
@@ -56,15 +56,24 @@ RiaSocketServer::RiaSocketServer( QObject* parent )
|
||||
m_nextPendingConnectionTimer->setInterval( 100 );
|
||||
m_nextPendingConnectionTimer->setSingleShot( true );
|
||||
|
||||
if ( !m_tcpServer->listen( QHostAddress::LocalHost, 40001 ) )
|
||||
int portNumber = riOctavePlugin::defaultPortNumber;
|
||||
if ( !RiaPreferences::current()->octavePortNumber().isEmpty() )
|
||||
{
|
||||
QString txt = "Disabled communication with Octave due to another ResInsight process running.";
|
||||
portNumber = RiaPreferences::current()->octavePortNumber().toInt();
|
||||
}
|
||||
|
||||
if ( !m_tcpServer->listen( QHostAddress::LocalHost, portNumber ) )
|
||||
{
|
||||
QString txt = QString( "Not able to communicate with Octave plugins. Failed to use port number : %1" ).arg( portNumber );
|
||||
|
||||
RiaLogging::warning( txt );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QString txt = QString( "Octave is using port: %1" ).arg( portNumber );
|
||||
RiaLogging::info( txt );
|
||||
|
||||
connect( m_nextPendingConnectionTimer, SIGNAL( timeout() ), this, SLOT( slotNewClientConnection() ) );
|
||||
connect( m_tcpServer, SIGNAL( newConnection() ), this, SLOT( slotNewClientConnection() ) );
|
||||
}
|
||||
|
||||
@@ -16,9 +16,21 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
namespace riOctavePlugin
|
||||
{
|
||||
const int qtDataStreamVersion = QDataStream::Qt_4_0;
|
||||
|
||||
// https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers
|
||||
// Use a port number in the dynamic/private range (49152-65535)
|
||||
const int defaultPortNumber = 52025;
|
||||
|
||||
inline const std::string portNumberKey()
|
||||
{
|
||||
return "RESINSIGHT_OCTAVE_PORT_NUMBER";
|
||||
}
|
||||
|
||||
} // namespace riOctavePlugin
|
||||
|
||||
Reference in New Issue
Block a user