question

Sakamoto Ko avatar image
1 Like"
Sakamoto Ko asked Sakamoto Ko commented

How to get the proper connection index after executing serveraccept(1).

Hi.


I'm researching Http communication between FlexSim.


I'd like the client to make the connection request after the server side is started.


If I use serveraccept(0), I can do that, but FlexSim will stop.


So I tried to execute serveraccept(1) in server.fsm before client.fsm send the connection request.


As a result, the connection was successful, but the server could not receive data from the client.


I tried to execute serverreceive() assuming the connection index was 1, but that seems to be a mistake.


If I execute serveraccept(1) before the client sends the request, how can I get the proper connection index?


server .fsm

client.fsm

FlexSim 21.0.10
httpcommunication socket
server.fsm (24.3 KiB)
client.fsm (25.2 KiB)
· 1
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

Jordan Johnson avatar image
2 Likes"
Jordan Johnson answered Sakamoto Ko commented

The serveraccept() command works in one of two ways, depending on the argument you pass in:

  • serveraccept(0) locks flexsim, waiting for an incoming connection. The return value is the
  • serveraccept(1) checks if, in that instant, something is attempting to connect. If nothing is trying to connect in that instant, then serveraccept(1) returns 0, and stops listening for something to connect, so you cannot get a good value later.

The HTTP API is newer, and so has a way to set callbacks, allowing asynchronous requests. The server*() commands are older, and so can only be used synchronously.

· 4
5 |100000

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