problem with udp connection : can not read

3 次查看(过去 30 天)
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 个评论
john gutsch
john gutsch 2018-7-11
Did you ever get this question answered? I am having the same problem.
xiaochun
xiaochun 2019-7-12
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?

请先登录,再进行评论。

回答(1 个)

Pulkit Goel
Pulkit Goel 2020-6-25
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.

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by