Azzera filtri
Azzera filtri

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 visualizzazioni (ultimi 30 giorni)
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('', 10000, 'NetworkRole', 'server')
The code for MATLAB (R2021a) Client Server is as follows:
client = tcpclient("",10000)
client =
tcpclient with properties
Address: ''
Port: 10000
NumBytesAvailable: 0
Show all properties, functions
data = [1 2 3 4 5];
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?

Risposta accettata

Nadia Shaik
Nadia Shaik il 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 usetcpclient’ or ‘tcpserver’ instead of ‘tcpip’ function as mentioned in the documentation.
Hope it helps!
  2 Commenti
Souarv De
Souarv De il 7 Apr 2022
@Nadia Shaik But In MATLAB R2016a there is no function called 'tcpserver' unlike MATLAB R2021a to create Server object. In MATLAB R2016a, 'tcpclient' function is there but with this function I think we can only create client object. So if I have two computers and I want to use the MATLAB R2016a as a server then what is the way (without use of 'tcpip') to make a server object there?
Nadia Shaik
Nadia Shaik il 11 Apr 2022
Hello Sourav,
As 'tcpip' function will be removed in the future releases, for compatibility reasons I would suggest you to kindly upgrade the MATLAB version to R2021a and use 'tcpserver' function to create Host Server.
Hope it helps!

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by