How to receive signed integer through socket
Mostrar comentarios más antiguos
Hi, I need Mathlab to receive integer values from a system for testing several data filters. I have written the server code in mathlab and the client code that sends the integer values in the system. The connection is established and data is sent and received, but mathlab has problems interpreting the received values.
For example, if a send integer -40, mathlab reads it and interpret it as -620756993
I guess it is just a data type problem, but I am new in mathlab world, and have no idea about how to get the correct values.
This is the Mathlab script I am using:
clear
tcpipServer = tcpip('0.0.0.0', 8181, 'NetworkRole', 'Server');
set(tcpipServer, 'InputBufferSize', 1024);
fopen(tcpipServer);
while true
rawData = fread(tcpipServer,1,'int32');
rawData % this line shows the wrong value
end
Any help will be appreciated!
Thanks
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre TCP/IP Communication en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!