From: Forest Date: Thu, 24 Sep 2020 17:35:01 +0000 (-0700) Subject: Poll for socket avail and handle send errors X-Git-Tag: 1.0.0~27^2~2 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=85173accd420eb45df2050e875fafd046ef0bf8b;p=rhonda%2Fimpostor.hazel.git Poll for socket avail and handle send errors --- diff --git a/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs b/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs index f0be655..f6020f5 100644 --- a/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs +++ b/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs @@ -214,9 +214,16 @@ namespace Hazel.Udp.FewerThreads try { - this.socket.SendTo(msg.Buffer, 0, msg.Buffer.Length, SocketFlags.None, msg.Recipient); + if (this.socket.Poll(Timeout.Infinite, SelectMode.SelectWrite)) + { + this.socket.SendTo(msg.Buffer, 0, msg.Buffer.Length, SocketFlags.None, msg.Recipient); + } + } + catch (Exception e) + { + this.Logger.WriteError("Error in loop while sending: " + e.Message); + Thread.Sleep(1); } - catch { } } }