question

Luke H avatar image
0 Likes"
Luke H asked Regan Blackett answered

how to use flexsim socket communication with server and client

Hi, i've been trying to use the worked examples from @Logan Gold on using a server and a client via using sockets but after trying to run the example not much seems to happens on my software with it not returning a 1 to show the client has connected, i kept his code with only changing the ip address and port to my own can someone please show me where i've gone wrong or where the values would be returned to as no console pops up showing these values

FlexSim 19.1.2
flexsim 19.1.2socketsserver and client
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Regan Blackett avatar image
0 Likes"
Regan Blackett answered

@Luke H

I used this document about 6 years ago to to build a training module for using socket connections. Maybe this will help.

https://cloud.flexsim.com/index.php/s/o9QEyNvcDyfznWK

· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Ben Wilson avatar image Ben Wilson ♦♦ commented ·

Attaching the document directly in case the link ever dies in the future:

Creating a Socket Connection in FlexSim.pdf

1 Like 1 ·
Luke H avatar image Luke H commented ·

thank you this was quite helpful but can you clarify where the value of 1 would be displayed when the connection is made

0 Likes 0 ·
Regan Blackett avatar image Regan Blackett ♦ Luke H commented ·

You mean the value returned by serveraccept()? It's a value returned by the function and so needs to be stored in a variable like:

int client = serveraccept(0);

"client" now stores the result of whether or not a connection was made (1 for true, 0 for false)

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.