UDP socket stops receiving data
3 views (last 30 days)
Show older comments
I'm using UDP to exchange data between Matlab and another Windows application running on the same PC with Win 7.
Channel configuration:
u=udp('localhost',2000,'LocalPort',2001);
set(u,'InputBufferSize',30000);
set(u,'OutputBufferSize',30000);
fopen(u);
set(u,'Timeout',.1,'DatagramTerminateMode','Off');
I use the same channel both for sending and receiving data.
Function that reads:
allDataLen = u.BytesAvailable;
if allDataLen
[allData count]=fread(u,allDataLen);
Function that sends:
fwrite (u,messageData)
The system works for a lot (tens) of hours with tens of messages per second being transmitted and received. However sometimes the Matlab application stops detecting the received data (u.BytesAvailable==0). I checked with SocketSniff and the other application still sends messages. In this situation Matlab is still able to send data. I tried to close (with fclose(u)) and reopen the port but it doesn’t work. In order to make the port to work again I need to close and reopen it in a new instance of Matlab.
Is that a bug?
Roberto
1 Comment
Answers (0)
See Also
Categories
Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!