From 85173accd420eb45df2050e875fafd046ef0bf8b Mon Sep 17 00:00:00 2001 From: Forest Date: Thu, 24 Sep 2020 10:35:01 -0700 Subject: [PATCH] Poll for socket avail and handle send errors --- .../ThreadLimitedUdpConnectionListener.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 { } } } -- 2.39.5