UdpClient, Receive() right after Send() does not work?

前端 未结 2 1587
甜味超标
甜味超标 2021-01-18 07:06

Consider the following code:

client.Send(data, data.Length, endpoint);
byte[] response = client.Receive(ref endpoint);

While, according to

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-18 07:41

    probably the remote host has firewall then couldn't response to request, before send request set the

    client.Client.ReceiveTimeout = 5000; 
    

    so when the response couldn't get the request you have a exception

提交回复
热议问题