You can refer to my custom push notifications tutorial here:
http://www.b4x.com/forum/basic4andr...ustom-push-notifications-server-included.html
I do not program in vb.net so I can't help you with that part. But to receive UDP packets you can use the following code:
Sub UDP_PacketArrived (Packet As UDPPacket)
Dim msg As String
msg = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8")
msgbox(msg, "message from server")
End Sub
The great thing with UDP is that you do not need to actively wait for a packet and you do not need to ping the server to keep a connection alive, because UDP is connectionless.
But I would recommend using a service if you want to receive packets when the app is in the background.