cannot receive udp packet

조회 수: 15 (최근 30일)
jinesh jhonsa
jinesh jhonsa 2019년 8월 24일
댓글: jinesh jhonsa 2019년 8월 24일
I am sending udp packets from udp client server app on windows 8. I can see the packet received on wireshark but I cannot receive it on matlab. I have turned off firewall and made sure everything required in following warning is satisfied. I can send udp packet on particular ip address and port but cannot receive it.Let me know what is the issue
Warning: A timeout occurred before the Terminator was reached.
'udp' unable to read any data. For more information on possible
reasons, see UDP Read Warnings.
u = udp('169.254.113.115',48569);
u.DatagramTerminateMode = 'off';
u.EnablePortSharing = 'on';
fopen(u);
fprintf(u,'Request Time sf\n');
data = fgets(u);
fclose(u);
delete(u);
clear u;

답변 (1개)

Walter Roberson
Walter Roberson 2019년 8월 24일
This is what you asked for. You deliberately configured udp to read across datagram boundaries until it sees a termination character, but you do not send any termination characters. Your data stream is
Hello1wHello1Hello1Hello1Hello1Hello1Hello1
You need to do one of the following:
  1. send a termination character (both sides need to agree and I recommend coding the property explicitly instead of defaulting it); or
  2. use datagram terminate mode so you read each packet even without termination; or
  3. read a particular number of characters with fread()
  댓글 수: 1
jinesh jhonsa
jinesh jhonsa 2019년 8월 24일
I added o as terminator still getting same error. here is the updated code
u = udp('169.254.113.115',48569);
u.DatagramTerminateMode = 'on';
u.EnablePortSharing = 'on';
u.Terminator = 111;
fopen(u);
data = fscanf(u);
fclose(u);
delete(u);
clear u;

댓글을 달려면 로그인하십시오.

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by