how to receive multicast packet

electro179

Active Member
Licensed User
Longtime User
hello


The multicast receiving doesn't work

I explain my network

My software on my computer sends a message
port = 3693
destination = 239.255.36.93


my code
B4X:
Sub Activity_Create(FirstTime As Boolean)   
UDPSocketAdn.Initialize("UDPSocket",3693,1000)

Obj1.Target = Obj1.GetContext
   Obj1.Target = Obj1.RunMethod2("getSystemService", "wifi", "java.lang.String")
   Obj1.Target = Obj1.RunMethod2("createMulticastLock", "mylock", "java.lang.String")
   Obj1.RunMethod2("setReferenceCounted", False, "java.lang.boolean") 


   Obj1.RunMethod("acquire")
end sub
Sub UDPSocketArtnetAdn_PacketArrived (Packet As UDPPacket)
   ToastMessageShow("received Multicast",True)

End Sub

and
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/> in the manifest

How to do to receive a message ?
Have I do a mistake ?
thank to for your help
 
Last edited:

Vader

Well-Known Member
Licensed User
Longtime User
Is the packet going through any routers? Most routers are configured to block UDP traffic.
 
Upvote 0

Vader

Well-Known Member
Licensed User
Longtime User
Actually, try this...

Change this line:
B4X:
UDPSocketAdn.Initialize("UDPSocket",3693,1000)


To this:
B4X:
UDPSocketAdn.Initialize("UDPSocketArtnetAdn",3693,1000)
 
Upvote 0

electro179

Active Member
Licensed User
Longtime User
sorry but I misspelled but my code is correct

Between 2 pc there is no problem I see the message with wireshark


An idea ?
 
Upvote 0

electro179

Active Member
Licensed User
Longtime User
yes if I send from android a udp packet, I can see on Wireshark.

I receive on android if it's not a multicast packet
 
Upvote 0

electro179

Active Member
Licensed User
Longtime User
who has already received a multicast packet ?

I work on android 2.3 (galaxy beam)

this code must be call once time and where ?

B4X:
   ReflectorADN.Target = ReflectorADN.GetContext
   ReflectorADN.Target = ReflectorADN.RunMethod2("getSystemService", "wifi", "java.lang.String")
   ReflectorADN.Target = ReflectorADN.RunMethod2("createMulticastLock", "mylock", "java.lang.String")
   ReflectorADN.RunMethod2("setReferenceCounted", False, "java.lang.boolean") ' not really necessary but safer

   ' needs <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
   ReflectorADN.RunMethod("acquire")

I am blocked in my program. :BangHead:

thank you for you help
 
Upvote 0

Vader

Well-Known Member
Licensed User
Longtime User
Why not in Activity_Create ?

B4X:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Activity1")
   
   If FirstTime Then
      ReflectorADN.Target = ReflectorADN.GetContext
      ReflectorADN.Target = ReflectorADN.RunMethod2("getSystemService", "wifi", "java.lang.String")
      ReflectorADN.Target = ReflectorADN.RunMethod2("createMulticastLock", "mylock", "java.lang.String")
      ReflectorADN.RunMethod2("setReferenceCounted", False, "java.lang.boolean") ' not really necessary but safer
      
      ' needs <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
      ReflectorADN.RunMethod("acquire")
   End If
 
Upvote 0

electro179

Active Member
Licensed User
Longtime User
Igmp

Hello

I tested the application : multicast test cool and my mobile can receive the multicast packet.

I saw with wireshark that this application send a message IGMP to join the group.
My question is : This protocole is required ? and if yes how to do with b4a

thank you
 
Upvote 0

electro179

Active Member
Licensed User
Longtime User
I'm going do it

do you think I must rewrite the library "network" or I can write a little program to send a command to join a group =>
- Create socket with library network and an other to join the group. There will be 2 different sockets. No ?
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Just curious if this ever went anywhere. I am having the same issue. I need to specify an address {joinGroup(InetAddress groupAddr)}.
 
Upvote 0

klarsys

Active Member
Licensed User
Longtime User
Anybody got success here?

I'm not able to receive any messages in Multicast Test Tool even if I run iTunes on my Windows machine or run 'perl send_mdns.pl' without any errors.
Does that mean my device does NOT support multicast messages?

Is there any other way to check?
 
Upvote 0
Top