hi, I want to make matlab communicate (several socket MATLAB customers) with a socket server (which is not matlab) via TCP/IP communication in real time but I have a delay pro
1 view (last 30 days)
Show older comments
Here is the identical code of customers matlab
t = tcpip('127.0.0.1', 7777, 'NetworkRole', 'client');
fopen(t);
while true
data =fscanf(t, '%c');
disp(data);
end
T
H
Warning: Unsuccessful read : A Timeout occured before the Terminator was reached...
1 Comment
Walter Roberson
on 10 Nov 2021
When reading separate characters, fread() often makes more sense than fscanf() '%c' . It might not fix your problem, but it might reduce it
data = fread(t, [1 1], 'uchar')
Which MATLAB release are you using? These days tcpclient() is recommended
Answers (3)
Bryan
on 10 Nov 2021
1 Comment
Walter Roberson
on 10 Nov 2021
I am not clear what you tried? Are you saying that when you used tcpclient() that the connection failed? Are you saying you used tcpclient() but using read() failed for it? [Note: tcpclient() uses read() and readline() not fread() -- and no fgets() for tcpclient() either.)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!