Wrong and Excessive values are received by the Host Server MATLAB while communicating Via TCP/IP Server Socket with Client Server MATLAB installed at different computer.
4 views (last 30 days)
Show older comments
I was trying to transfer data via TCP/IP Server Socket communication between two different version of MATLAB installed in two different computers. The Server computer has MATLAB version 2016a installed and the Client server has MATLAB 2021a installed in it.
The code for MATLAB (R2016a) Host Server is as follows:
server = tcpip('0.0.0.0', 10000, 'NetworkRole', 'server')
fopen(server)
The code for MATLAB (R2021a) Client Server is as follows:
client = tcpclient("172.26.45.99",10000)
client =
tcpclient with properties
Address: '172.26.45.99'
Port: 10000
NumBytesAvailable: 0
Show all properties, functions
data = [1 2 3 4 5];
write(client,data)
The code for MATLAB (R2016a) Host Server is as follows:
read_data = fread(server,server.BytesAvailable)
After running this code in host server machine the variable size "read_data" becomes 40 x 1 double instead of 5 x 1. The values received were attached with this mail. I donot have any clue why values are comming as wrong and to excessive. Can anyone guide me why such abnormal data is receiving by the host server?
0 Comments
Accepted Answer
Nadia Shaik
on 7 Apr 2022
Hello Sourav,
It is my understanding that the expected data size is not received at the server while using ‘tcpip’ function for server computer in MATLAB R2016a and ‘tcpclient’ function for client server in MATLAB R2021a.
You may use ‘tcpclient’ or ‘tcpserver’ instead of ‘tcpip’ function as mentioned in the documentation.
Hope it helps!
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!