MATLAB Answers

Script for reading UDP

4 views (last 30 days)
Angelo Forli
Angelo Forli on 16 Oct 2020
Answered: Urmila Rajpurohith on 19 Oct 2020
I am trying to read UDP packets coming trough Ethernet (this is the format I can see the incoming UDP from WireShark (see below), but then I am unable to read them (I get this error: 'Cannot bind address already in use').
I am using the following code:
remote_ip = '';
local_ip = '';
remote_port = 49153;
local_port = 7667;
u = udp(remote_ip,remote_port,'LocalHost',local_ip,'Localport',local_port);
u.ByteOrder = 'littleEndian';
u.EnablePortSharing = 'on';
u.DatagramTerminateMode = 'off';

Answers (1)

Urmila Rajpurohith
Urmila Rajpurohith on 19 Oct 2020
From the error message it seems that the port is already being used by another application ( or by an earlier run of your MATLAB script) . You might need to first restart your machine to free up the port ( or kill the process that is listening on that port).
Hope this helps!


Community Treasure Hunt

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

Start Hunting!