Clear Filters
Clear Filters

problem with udp connection : can not read

3 views (last 30 days)
Bayan Ghanem
Bayan Ghanem on 2 Jan 2017
Answered: Pulkit Goel on 25 Jun 2020
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
john gutsch
john gutsch on 11 Jul 2018
Did you ever get this question answered? I am having the same problem.
xiaochun
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?

Sign in to comment.

Answers (1)

Pulkit Goel
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.

Categories

Find more on Get Started with MATLAB 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!