Run Java Code in Matlab
6 次查看(过去 30 天)
显示 更早的评论
Hello Everyone,
I want to run the following Java Code in Matlab to open a UDP socket and listen for incoming multicast datagrams. ------------------------------------------------------------------------------------------------------------
socket = java.net.MultiSocket(streamPort);
socket.joinGroup(java.net.InetAddress.getByName(streamIP));
socket.setReuseAddress(1);
packet = java.net.DatagramPacket(zeros(1, intmax('uint16'), 'int8'), intmax('uint16'));
socket.receive(packet);
socket.leaveGroup(InetAddress.getByName(streamIP));
socket.close;
msg = packet.getData;
msg = msg(1:packet.getLength);
------------------------------------------------------------------------------------------------------------
I am trying to do the same in matlab but i get error: Undefined variable java or class java.net.MultiSocket. How to add javaclasspath?
Regards
7 个评论
Geoff Hayes
2016-3-9
PTP - what happens when you create the received String variable? Are you expecting something else (a valid string) or ...? What data type is dgram? Does dgram.GetData() return an array of bytes?
I am unable to read the data received since it is some random binary characters. Should it be non-random instead?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Java Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!