How to interrupt MATLAB TCPIP server
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Vahe
am 18 Dez. 2013
Beantwortet: Walter Roberson
am 18 Dez. 2013
I'm writing a program to read data from device. The device is connected to one PC and I'm trying to read data from another PC. I'm using MATLAB TCPIP command (the PC which is connected to device is server, and another one is client). My problem is how to terminate the server tcpip connection if there is no any request from client side for given time period. The fragment of the program from server side is following:
while (1)
tcpipServer_PV = tcpip('0.0.0.0',44001,'NetworkRole','Server')
fopen(tcpipServer_PV);
PV_Temp = rand(1) % rand(1) as an example
fwrite(tcpipServer_PV,PV_Temp,'double');
pause(1);
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 18 Dez. 2013
You seem to be setting up the server each time through the loop, which is not efficient. You do not seem to be closing the server at the end of the loop, which is a problem.
Your code sample does not attempt to read from the client, so there is nothing there to interrupt.
See https://www.mathworks.com/matlabcentral/newsreader/view_thread/153485 for a discussion on how to time out.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!