Skip to content

Commit

Permalink
Add commnets on user_specified_port.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakio815 committed Dec 18, 2024
1 parent 33cca90 commit e9642b5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/federated/RTI/rti_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,23 @@ void initialize_RTI(rti_remote_t* rti) {
rti_remote->num_feds_proposed_start = 0;
rti_remote->all_federates_exited = false;
rti_remote->federation_id = "Unidentified Federation";
// The federate and RTI both initialize the user_specified_port as 0. For the RTI, when the user_specified_port is 0,
// it recognizes that there was no user input to assign a port and assigns the port to the DEFAULT_PORT, which is
// 15045.

// For the federate, when the user_specified_port is 0, it also recognizes that there was no user input and makes the
// OS assign the port.

// The create_TCP_server gets this input argument port, which is actually the user_specified_port for both RTI and
// federate. To distinguish whether the RTI or federate is calling this function, I changed the initial value of the
// RTI's port as 1.

// We need to distinguish whether the RTI or federate called the create_TCP_server function for two reasons.

// First, we should set the default port, which RTI and federate differ.
// Next, RTI increments the port number starting from 15045, when the port binding fails. However, the federate does
// not increment the port number and try binding.
// For more info, check this pr. https://github.com/lf-lang/reactor-c/pull/505
rti_remote->user_specified_port = 1;
rti_remote->final_port_TCP = 0;
rti_remote->socket_descriptor_TCP = -1;
Expand Down

0 comments on commit e9642b5

Please sign in to comment.