I want to use clientreceive() to read one integer sent from the server. Is it possible to read four bytes from the socket and convert it to an integer in FlexScript?
I want to use clientreceive() to read one integer sent from the server. Is it possible to read four bytes from the socket and convert it to an integer in FlexScript?
Unfortunately clientreceive() only returns strings and FlexSim's string type is not so UTF-8 compliant that you can use that to transmit any integer.
I have written a module a while back that can transmit and receive binary data but it was for 17.0, I think, so it needs an upgrade here and there. Let me know by email if you are interested.
@Yue Y As Mischa said the FlexScript command cannot do this. If you use the c++ version of the command from a module then you could convert the bytes into an integer.
thank you! How can I use c++ version in the Script? Do I just click the "C" button? In this mode, how can I convert the bytes into an integer, is there any function I can use?
To use the c++ version I recommend using the module SKD. Otherwise if you put c++ into the model then you will have to compile it every time.
I want to read a long message using clientreceive but I don't know the length of the message ahead of time. So that the server would send an integer first, indicating the length of the message. Then FlexSim should read the integer first and then read these amount of characters from the socket. Is it possible? Thank you!
You could send the integer as a string padded to a certain length. Then remove the padding and parse the string as an integer in FlexScript. That way you wouldn't have to use c++.
13 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved