How to use TCP/IP for the communication between more than two instances of MATLAB on a same computer?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have found the below link as an example of using TCP/IP to send and receive data between two instances of MATLAB:
However, I would like to know how can one use TCP/IP for example to send and receive data between three instances of MATLAB? It would be great if someone explain this with a simple example.
0 comentarios
Respuestas (1)
Ran Chen
el 22 de Ag. de 2018
Hi,
More than one servers can be created in a MATLAB session. You may create two servers(naming it as server1, server2) at the same time in a MATLAB session, and create two client instances of MATLAB(client1, client2). Server1 communicates with Client1, Server2 communicates with Client2. Since Server1 and Server2 are in the same MATLAB session so they can share data or communicate via Workspace.
You may refer to the code in the attached link:
https://www.mathworks.com/matlabcentral/fileexchange/63328-matlab-server-example-communicate-with-two-clients
2 comentarios
Souarv De
el 5 de Abr. de 2022
Editada: Souarv De
el 5 de Abr. de 2022
@Ran Chen I have an querry regarding the code you have written. It will be very much helpful for me if you kindly explain it in more details. In the above code I am only interested between single communication between Server (t3) and Client (t4).
Q1) Why do you set buffersize in both t3 and t4? What is it's requirement here?
Q2) In t4 clinet section you have set timeout period of 20. Does it mean client will wait for 20 sec to get response from the server failing which the MATLAB throws some error.
Q3) As I see you are sending 3 data [1 5 0] in an array via server t3 but why do you write fread(t4,[1,3],'double'); in t4 client session. what is this [1 3] signifies. What if I donot write 'double'. And I am not able to guess what would be the output also.
Please let me know.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!