Android Question UDP Packet Receiving

Nitin Joshi

Active Member
Licensed User
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

B4X:
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

B4X:
Sub UDP_PacketArrived (Pkt As UDPPacket)
    UDPRcvMsg = BytesToString(Pkt.Data, Pkt.Offset, Pkt.Length,"UTF8")
 End Sub
 
Top