- https://www.mathworks.com/help/instrument/udpport.html
- https://www.mathworks.com/help/instrument/tcpserver.html
How to receive tcp/udp packet?
6 ビュー (過去 30 日間)
古いコメントを表示
PC_A : shoot packet (Colasoft packet builder)
PC_B : receive it (Wireshark)
Wireshark received it but Matlab is an error(not connected)!
search various web site but not obvious
show me a simple example code!
0 件のコメント
回答 (1 件)
Narvik
2024 年 10 月 30 日 9:26
Hi,
As per my understanding, you are trying to receive TCP/UDP packets in MATLAB and encountering connection errors.
To receive packets, make sure you have the Instrument Control Toolbox installed, your firewall permits connections on the specified port, and the network configurations between PCs are correctly set up.
Refer to the following code to set up a basic UDP and TCP receiver:
% Create UDP object
udpReceiver = udpport("LocalPort", 12345);
% Read data
data = read(udpReceiver, 100, "uint8");
% Create TCP server object
tcpReceiver = tcpserver("0.0.0.0", 12345);
% Wait for connection and read data
while ~tcpReceiver.Connected
pause(0.1);
end
data = read(tcpReceiver, tcpReceiver.NumBytesAvailable, "uint8");
Refer to the following documentation for more information on "uddport" and "tcpport" MATLAB functions:
Hope this helps!
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!