How can i send data in using "UDP" Command?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I wanted to send data in network .Firstly ,I have loaded file name as "target.dat" .
this is the code i used to send data.
HOST1 = '192.168.3.13';
SOURCE_PORT1 = 4038;
LOCAL_PORT1 = 1020;
Buffer_size1 = 50000;
u1 = udp(HOST1, SOURCE_PORT1,'Localport' ,LOCAL_PORT1);
set(u1,'inputBufferSize',Buffer_size1);
set(u1,'outputBufferSize',Buffer_size1);
fopen(u1);
flushinput(u1); %flusing i/p o/p buffers
flushoutput(u1);
disp("sent")
its showing error as:
"Unsuccessful open: Address already in use: Cannot bind"
Please, help me out sloving this error.
I restarted matlab application also, still same same error is appearing.
0 commentaires
Réponses (1)
Koundinya
le 29 Mai 2019
Like the error message mentions, 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).
You can enable port sharing to allow multiple UDP sockets to bind to the port :
u1 = udp(HOST1, SOURCE_PORT1,'Localport' ,LOCAL_PORT1);
u1.EnablePortSharing = 'on';
Also make sure to close the UDP socket at the end to avoid running into such problems :
fclose(u1);
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!