フィルターのクリア

Programmatically avoiding UDP Error "Cannot bind address already in use"

10 ビュー (過去 30 日間)
Matthew Mellor
Matthew Mellor 2016 年 7 月 15 日
回答済み: Pulkit Goel 2020 年 6 月 25 日
I've been using udp to receive sensor data into matlab. Occasionally I'll have to stop my matlab coding while it is running which keeps it from closing the udpObject that I was using. This means that the next time I run my code I get the error "Cannot bind address already in use". In order to run the code again successfully I have to run the command: fclose(instrfindall). I wondering if at the start of my code before I try to bind to the udp address there is a way to programmatically avoid the "Cannot bind address already in use".
Possibly something like this:
if addressAlreadyInUse
fclose(instrfindall);
end
fopen(udpObject);
Anyone know an appropriate condition to tell if addressAlreadyInUse? Thanks

回答 (1 件)

Pulkit Goel
Pulkit Goel 2020 年 6 月 25 日
One way to get around this problem is to enable port sharing before opening the udp object:
udpObject.EnablePortSharing='on';
This allows multiple object to be created with same port. Not the exact solution to what you want, but it works.

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by