Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Param name new name in the form "hostname:port/proto" is not right in FGOutputSocket::SetOutputName #882

Open
fishpro opened this issue Apr 8, 2023 · 4 comments
Labels

Comments

@fishpro
Copy link

fishpro commented Apr 8, 2023

Describe the issue
FGOutputSocket.cpp

void FGOutputSocket::SetOutputName(const string& fname)
{
  // tokenize the output name
  size_t dot_pos = fname.find(':', 0);
  size_t slash_pos = fname.find('/', 0);
  
  string name = fname.substr(0, dot_pos);
  
  string proto = "TCP";
  if(dot_pos + 1 < slash_pos)
    proto = fname.substr(dot_pos + 1, slash_pos - dot_pos - 1);//bug not right dot_pos 
  
  string port = "1138";
  if(slash_pos < string::npos)
    port = fname.substr(slash_pos + 1, string::npos); //bug not right slash_pos 
  
  // set the model name
  Name = name + ":" + port + "/" + proto;
  
  // set the socket params
  SockName = name;
  
  SockPort = atoi(port.c_str());
  
  if (to_upper(proto) == "UDP")
    SockProtocol = FGfdmSocket::ptUDP;
  else // Default to TCP
    SockProtocol = FGfdmSocket::ptTCP;
}

param name new name in the form "hostname:port/proto" is not right
but "hostname:proto/port" is right?

@seanmcleod seanmcleod changed the title param name new name in the form "hostname:port/proto" is not right in FGOutputSocket::SetOutputName Param name new name in the form "hostname:port/proto" is not right in FGOutputSocket::SetOutputName Apr 8, 2023
@seanmcleod
Copy link
Member

Okay, so what you're pointing out is that when parsing the input parameter fname the assumption is that it has the form:

hostname:proto/port

But when then generating the model name, Name, from the components based on parsing, it's generating the model name as:

hostname:port/proto

@fishpro
Copy link
Author

fishpro commented Apr 8, 2023

yes,
That's what it means

@seanmcleod
Copy link
Member

Okay and looking at the code that calls FGOutputSocket::SetOutputName() the correct format is:

hostname:proto/port.

bool FGOutputSocket::Load(Element* el)
{
if (!FGOutputType::Load(el))
return false;
SetOutputName(el->GetAttributeValue("name") + ":" +
el->GetAttributeValue("protocol") + "/" +
el->GetAttributeValue("port"));

So the model name Name is incorrect. Not sure off-hand where the model name Name is used, possibly for display purposes somewhere.

I see the comment in the header file is incorrect, it has swapped port and protocol around.

So we should update the comment in the header file and updated the Name.

Do you want to submit a pull request (PR) or do you want me to go ahead and generate a pull request?

@bcoconni
Copy link
Member

Do you want to submit a pull request (PR) or do you want me to go ahead and generate a pull request?

I guess you can submit the PR @seanmcleod.

@bcoconni bcoconni added the bug label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants