]> git.deb.at Git - rhonda/impostor.hazel.git/commitdiff
Poll for socket avail and handle send errors
authorForest <forest@innersloth.com>
Thu, 24 Sep 2020 17:35:01 +0000 (10:35 -0700)
committerForest <forest@innersloth.com>
Thu, 24 Sep 2020 17:35:01 +0000 (10:35 -0700)
Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs

index f0be65534d499161bea9b3db39562d252f982a06..f6020f594a92fd91b5af8cca4dc7cc31628646ec 100644 (file)
@@ -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 { }
             }
         }