From c007cfc88a9bf018bfcfbaf8f3e176215cca4bec Mon Sep 17 00:00:00 2001 From: Mrockwell2 <120338765+Mrockwell2@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:47:45 -0500 Subject: [PATCH] Fixed error message for sims with the same port number (#1776) * Fixed error message for same port number * Fixed return values --- .../VariableServer/VariableServerListenThread.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp b/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp index 4c43bfd6c..0dbc11390 100644 --- a/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp +++ b/trick_source/sim_services/VariableServer/VariableServerListenThread.cpp @@ -112,21 +112,24 @@ int Trick::VariableServerListenThread::init_listen_device() { // Called from init jobs int Trick::VariableServerListenThread::check_and_move_listen_device() { - int ret ; + int ret = 0; if (_user_requested_address) { /* The user has requested a different source address or port in the input file */ _listener->disconnect(); ret = _listener->initialize(_requested_source_address, _requested_port); - _requested_port = _listener->getPort(); - _requested_source_address = _listener->getHostname(); + if (ret != 0) { message_publish(MSG_ERROR, "ERROR: Could not establish variable server source_address %s: port %d. Aborting.\n", _requested_source_address.c_str(), _requested_port); - return -1 ; + + ret = -1; } + + _requested_port = _listener->getPort(); + _requested_source_address = _listener->getHostname(); } - return 0 ; + return ret ; } void * Trick::VariableServerListenThread::thread_body() {