I am wondering whether I can set a timeout value for UdpClient receive method.
I want to use block mode, but because sometimes udp will lost packet, my program udpCl
There is a SendTimeout and a ReceiveTimeout property that you can use in the Socket of the UdpClient.
SendTimeout
ReceiveTimeout
Socket
UdpClient
Here is an example of a 5 second timeout:
var udpClient = new UdpClient(); udpClient.Client.SendTimeout = 5000; udpClient.Client.ReceiveTimeout = 5000; ...