Can i get the client ip and port which connect to server socket in flexsim

Can i get the client ip and port which connect to server socket in flexsim

yexioamu
Not applicable
1,018 Views
8 Replies
Message 1 of 9

Can i get the client ip and port which connect to server socket in flexsim

yexioamu
Not applicable

[ FlexSim 21.2.4 ]

Can i get the remote client ip and port which connect to server socket in flexsim

0 Likes
Accepted solutions (1)
1,019 Views
8 Replies
Replies (8)
Message 2 of 9

natalie_white
Not applicable

You create a server socket that listens for connections to a specified port using servercreatemain(). So, you choose the port number. Your client needs to know the IP address of your server, but I'm not sure if you can access your client's IP address.

Does this help, or were you trying to ask about something else? Would an example of using a socket be useful?

Message 3 of 9

yexioamu
Not applicable
I mean that I create a server socket in flexsim, I have several clients with different ip and port, when they connect to the server socket, I want to know which client connect, and the client won’t send its own ip and port in the message
0 Likes
Message 4 of 9

natalie_white
Not applicable
Got it. Are you trying to send the message with clientsend()? This function can only send a string.

If you're able to attach your model, that would be helpful.

0 Likes
Message 5 of 9

yexioamu
Not applicable
The client is a wms system of my company, and it is hard to modify the message send to server socket. Does the server socket can get the connect client ip in flexsim


0 Likes
Message 6 of 9

natalie_white
Not applicable

You can try something similar to the solution from your previous question, found here. After the runprogram() command, you would need to read the text file and send the local computer's IP over the socket.

0 Likes
Message 7 of 9

yexioamu
Not applicable

It seems like that you have not understand my question, i can't control the message content that client send, i can only use a server socket building in flexsim to wait client connections and accept meaasge. In this background, i want to know the client ip and port which connect to the server socket in flexsim.

0 Likes
Message 8 of 9

philboboADSK
Autodesk
Autodesk
Accepted solution

The FlexScript socket commands do not give you access to the connecting client's ip address. The serveraccept() function returns an index for the client connection that is subsequently used to receive messages from that client using serverreceive().

If you want more control over the communication than you get with the FlexScript commands, use external code, such as Python or C++. See Connecting to External Code.

See also accept function (C++) or socket.accept (Python).



Phil BoBo
Sr. Manager, Software Development
0 Likes
Message 9 of 9

jason_lightfoot_adsk
Autodesk
Autodesk

Hi @yexioamu, was one of Natalie White's or Phil BoBo's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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