problem with udp connection : can not read
2 views (last 30 days)
Show older comments
Hello, I am trying to exchange data between two computers with UDP in MATLAB, here is the code
%sender
u=udp('192.168.91.88', 9090, 'LocalPort', 9091, 'InputBufferSize', 8192, 'TimeOut', 99);
fopen(u);
A=1:10;
fwrite(u,A);
fclose(u)
delete(u)
%rcvr
u1=udp('192.168.91.53', 9091,'LocalPort', 9090);
set(u1, 'OutputBufferSize', 8192)
set(u1, 'TimeOut', 99)
fopen(u1)
fread(u1)
fclose(u1)
delete(u1)
but this message keep appera
Warning: Unsuccessful read: The specified amount of data was not returned within the Timeout period.
what should I do. where is the mistake??
Regards
2 Comments
xiaochun
on 12 Jul 2019
I also have this same problem. I did a lot of search online, the reason seems that after fopen the udp, the BytesAvailouble is 0. But I have no idea how to make it more than zero?
Answers (1)
Pulkit Goel
on 25 Jun 2020
This issue may arise due to firewall blocking udp packets you are trying to recieve. You can try making some ports bypass your firewall using following steps:
Windows Defender Firewall > Inbound Rules > New Rule > Select Port > Next > Select UDP > Specify Porr of your Choice (you may select all, which is not recommended) > Allow the Connection > Next > Next > Enter name and description (for your convininence) > Finish
Follow same for Outbound Rules.
Also, try ignoring 'InputBufferSize' and 'OutputBufferSize' parameters and see if it is working then. You should also try checking if the packets are being transferred using Wireshark software.
0 Comments
See Also
Categories
Find more on Get Started with Aerospace Blockset 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!