{
while (this.isActive)
{
- if (this.socket.Poll(Timeout.Infinite, SelectMode.SelectRead))
+ if (this.socket.Poll(1000, SelectMode.SelectRead))
{
+ if (!isActive) break;
+
EndPoint remoteEP = new IPEndPoint(this.EndPoint.Address, this.EndPoint.Port);
MessageReader message = MessageReader.GetSized(BufferSize);
try
{
this.socket.SendTo(msg.Span.GetUnderlyingArray(), msg.Span.Offset, msg.Span.Length, SocketFlags.None, msg.Recipient);
}
+ else
+ {
+ this.Logger.WriteError("Socket is no longer able to send");
+ break;
+ }
}
catch (Exception e)
{
// Flush outgoing packets
this.sendQueue?.CompleteAdding();
+
if (wasActive)
{
this.sendThread.Join();