The receive method is always blocking so you will either want to use the BeginReceive method or thread the Receive method.
Here is an example using threading...
VB Code:
Module Module1
Delegate Sub dDataReceived(ByVal Data As String)
Sub Main()
Dim UDPWorker As New Worker
Dim tWorker As New Threading.Thread(AddressOf UDPWorker.Start)
tWorker.Start()
Console.WriteLine("UDP Client is listening...Press Enter to exit.")
Console.ReadLine()
UDPWorker.Active = False
End
End Sub
End Module
Public Class Worker
Public Active As Boolean = True
Private udpClient As New Net.Sockets.UdpClient(9999)
Public Sub Start()
Do While Active
Dim Data() As Byte = udpClient.Receive(New Net.IPEndPoint(Net.IPAddress.Any, 0))
Console.WriteLine(Text.Encoding.UTF8.GetString(Data))
Loop
End Sub
End Class