I am developing an application in VB.NET which uses the Sockets namespace - UDPClient(). I am having trouble as when I wait to receive some data from an ipaddress it just waits forever.

I believe my problem is related to timeout and would like to know how best to set the value?

My Example Code:

Code:
Dim addr As IPAddress = System.Net.IPAddress.Parse("169.1.1.1")
Dim udpClient As New System.Net.Sockets.UdpClient()
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Hello")
Dim remoteIpEndPoint As New System.Net.IPEndPoint(addr.Address, 100)

Try
   udpClient.Send(sendBytes, sendBytes.Length, remoteIpEndPoint)

    ' Blocks until a message returns on this socket from a remote host
    Dim receiveBytes As [Byte]() = udpClient.Receive(remoteIpEndPoint)
    Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)

    Console.WriteLine(returnData.ToString())
Catch e As Exception
    Console.WriteLine(e.ToString())
End Try
The above code works fine until the receiveBytes line where it just hangs until it receives some data, which could be forever. I need to say "Wait for 5 seconds and if nothing then continue".

Can somebody please help????