Socket communication Flexsim (Windows) and Linux c++ script

Socket communication Flexsim (Windows) and Linux c++ script

Catarina_Rema
Not applicable
236 Views
5 Replies
Message 1 of 6

Socket communication Flexsim (Windows) and Linux c++ script

Catarina_Rema
Not applicable

[ FlexSim 24.1.0 ]

I've been trying to establish a socket communication between Flexsim and a Linux c++ script, but i had no sucess. Someone can help me. I put here the photos of each code i'm using.

0 Likes
Accepted solutions (1)
237 Views
5 Replies
Replies (5)
Message 2 of 6

JordanLJohnson
Autodesk
Autodesk
What fails, exactly? Does the C++ code accept the connection? Or does FlexSim not receive the response?

Also, be aware that the On Run Stop trigger fires every time you click the stop button. I would probably just make sure the socket is connected on reset, and then leave it open.

.


Jordan Johnson
Principal Software Engineer
>

0 Likes
Message 3 of 6

Catarina_Rema
Not applicable

c++ doesn't establish the connection, i'm not receiving the "Hello server" message from Flexsim. And neither the "conncetion accepted" from the c++ code.

0 Likes
Message 4 of 6

JordanLJohnson
Autodesk
Autodesk
Accepted solution

I can't debug your C++ program. But I made this demo that works on a local computer (127.0.0.1).

EchoServerDemo.fsm

echo_server.py

The python script makes a simple socket echo server. If you have python installed, you can run the file from a command prompt like so:

cd path/to/folder
python -m echo_server.py

If you run that file, the server just sends and receives in a loop. Once the server is running, you can run the model and see that the model is sending and receiving via the socket. For me, this all worked fine, so I don't think it's an issue with FlexSim's socket code.

It looks like you're trying to connect to a different computer. Sometimes firewalls or other network issues can prevent sockets.

Note: I tested this with Python 3.11.

.


Jordan Johnson
Principal Software Engineer
>

Message 5 of 6

Jeanette_Fullmer
Community Manager
Community Manager

Hi @Catarina, was Jordan Johnson's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes
Message 6 of 6

Catarina_Rema
Not applicable

hi

I was able to establish the connection. So my previous code was correct, but actually there was a firewall preventing the connection like you said.

Thank you

0 Likes