ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 03-13-2014
Simon Moosbrugger Simon Moosbrugger is offline
Flexsim User
 
Join Date: Mar 2014
Posts: 4
Downloads: 3
Uploads: 0
Thanks: 2
Thanked 5 Times in 1 Post
Rep Power: 0
Simon Moosbrugger is on a distinguished road
Default clientcreate() returns 0

hey there,

i wrote this piece of code in the OnRunStart trigger. i wanted to initiate a socket communication with a server written in C#

Code:
int socknum = clientcreate();
string host = "127.0.0.1";
int sockport = 13000;
clientconnect(socknum, host, sockport);
clientsend(socknum,"this is flexsim");
but the cliencreate(); always returns 0. In the command help is written that if an error occurs, this function returns 0. but what kind of error? all logs are also empty.

I'm using FlexSimn 7.0.6.

Thanks for helping!
  #2  
Old 03-13-2014
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

Hello Simon,

I have not any experience in socket communication, I was just looking for threads:
Perhaps flexsim still expects the communication from a c++ node rather than a flexscript node mentioned in Nico's thread.

Jörg
  #3  
Old 03-17-2014
Simon Moosbrugger Simon Moosbrugger is offline
Flexsim User
 
Join Date: Mar 2014
Posts: 4
Downloads: 3
Uploads: 0
Thanks: 2
Thanked 5 Times in 1 Post
Rep Power: 0
Simon Moosbrugger is on a distinguished road
Default socketinit(); is the solution

finally found the solution. socketinit() has to be called first - some background processes are initalized there. now it works fine!

Code:
socketinit();
int socknum = clientcreate();
string host = "127.0.0.1";
int sockport = 13000;
clientconnect(socknum, host, sockport);
clientsend(socknum,"this is flexsim");

Last edited by Simon Moosbrugger; 03-17-2014 at 04:48 AM.
The Following 5 Users Say Thank You to Simon Moosbrugger For This Useful Post:
Tom David (03-19-2014)



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.