udp connection fails when wifi is disconnected

조회 수: 9 (최근 30일)
KnightHawk
KnightHawk 2025년 2월 13일
편집: Abhiram 2025년 3월 26일
I am trying to create a udp connection to the local host, if I am connected to wifi, it is successful but if I disconnect from the wifi, I get the errror below. How is the wifi connection affecting this?
>> u = matlabshared.network.internal.UDP( ...
'RemoteHost','127.0.0.1', ...
'RemotePort',14550, ...
'LocalPort',14570, ...
'EnablePortSharing',true);
>> u.connect
Cannot create a communication link with the remote server. Please check the input arguments(ADDRESS and PORT) and make sure
the server is running.
Additional Information: resolve: Host not found (authoritative) [asio.netdb:1]
  댓글 수: 3
KnightHawk
KnightHawk 2025년 2월 14일
This appears to only happen in Ubuntu (specifically 22.04), windows doesn't have a problem.
Ishaan
Ishaan 2025년 2월 21일
편집: Ishaan 2025년 2월 21일
Hey,
I noticed you are using a function that I couldn't find in the official MATLAB documentation. However, there's a function called "udpport" that provides similar functionality for UDP connections. I have tried it on my Windows machine, and it works well, even when I'm not connected to Wi-Fi.
Here is an example showcasing how you can use it.
>> u = udpport("datagram", "LocalPort", 14570, "EnablePortSharing", true);
>> write(u, data, "uint8", "127.0.0.1", 14550);
>> dataReceived = read(u, numBytes, "uint8");
For more information on "udpport", please refer to the following documentation link:

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

답변 (1개)

Abhiram
Abhiram 2025년 3월 26일
편집: Abhiram 2025년 3월 26일
It seems that some UDP features are unable to resolve local IP addresses when the machine is offline on some Linux distributions.
This is a known issue and has been reported as a bug by MathWorks Support as specified in the given Bug Reports page:

카테고리

Help CenterFile Exchange에서 .NET Client Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by