Run Java Code in Matlab
Mostrar comentarios más antiguos
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 comentarios
PTP
el 8 de Mzo. de 2016
Geoff Hayes
el 8 de Mzo. de 2016
PTP - this looks to be the same code posted at http://stackoverflow.com/questions/21734856/listening-to-a-multicast-udp-address. Have you tried contacting the author of this code?
per isakson
el 9 de Mzo. de 2016
PTP
el 9 de Mzo. de 2016
Geoff Hayes
el 9 de Mzo. de 2016
PTP - please clarify how the new code is related to your MATLAB program.
Geoff Hayes
el 9 de Mzo. de 2016
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?
Respuestas (0)
Categorías
Más información sobre Java Package Integration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!