N Nitin Joshi Active Member Licensed User Longtime User Nov 3, 2018 #1 I have observed that B4A does not receive UDP packet unless and until sent sub is not executed. Please refer both codes, for UDP packet reception & UDP packet sending. My question is...Is there any way to receive UDP packet without initializing UDP_Send sub? Code UDP packet sending Code: Copy Sub UDP_Send (Str As String, remoteIP As String) Dim Data() As Byte UDPSkt.Initialize("UDP", 4211, 255) Data=Str.GetBytes("UTF8") UDPPkt.Initialize(Data, remoteIP, 4210) UDPSkt.Send(UDPPkt) End Sub Code UDP packet Receiving Code: Copy Sub UDP_PacketArrived (Pkt As UDPPacket) UDPRcvMsg = BytesToString(Pkt.Data, Pkt.Offset, Pkt.Length,"UTF8") End Sub
I have observed that B4A does not receive UDP packet unless and until sent sub is not executed. Please refer both codes, for UDP packet reception & UDP packet sending. My question is...Is there any way to receive UDP packet without initializing UDP_Send sub? Code UDP packet sending Code: Copy Sub UDP_Send (Str As String, remoteIP As String) Dim Data() As Byte UDPSkt.Initialize("UDP", 4211, 255) Data=Str.GetBytes("UTF8") UDPPkt.Initialize(Data, remoteIP, 4210) UDPSkt.Send(UDPPkt) End Sub Code UDP packet Receiving Code: Copy Sub UDP_PacketArrived (Pkt As UDPPacket) UDPRcvMsg = BytesToString(Pkt.Data, Pkt.Offset, Pkt.Length,"UTF8") End Sub
Erel B4X founder Staff member Licensed User Longtime User Nov 4, 2018 #2 I don't understand your code. You don't need to send a packet in order to receive packets. Make sure to only initialize UDPSocket once when the program starts. Service_Create of the starter service is a good place for this. Upvote 0
I don't understand your code. You don't need to send a packet in order to receive packets. Make sure to only initialize UDPSocket once when the program starts. Service_Create of the starter service is a good place for this.