You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Riemer, Björn" <bj...@fokus.fraunhofer.de> on 2011/01/25 11:14:14 UTC
Patch: UdpAppender with Multicast TTL
Hi*,
i've enhanced the UdpAppender in such a way that you could specify the MulticastTTL value in the configuration file.
By setting this value greater than 1 the log messages could pass routers between subnets in Multicast mode.
Index: src/Appender/UdpAppender.cs
===================================================================
--- src/Appender/UdpAppender.cs (revision 1063197)
+++ src/Appender/UdpAppender.cs (working copy)
@@ -284,6 +284,15 @@
get { return m_encoding; }
set { m_encoding = value; }
}
+
+ /// <summary>
+ /// Gets or sets the Multicast HopLimit of the Socket.
+ /// </summary>
+ public int MulticastHopLimit
+ {
+ get { return m_multicastHopLimit; }
+ set { m_multicastHopLimit = value; }
+ }
#endregion Public Instance Properties
@@ -499,6 +508,15 @@
this.Client = null;
}
+ try
+ {
+ this.Client.Client.SetSocketOption(SocketOptionLevel.IP,
+ SocketOptionName.MulticastTimeToLive,
+ this.MulticastHopLimit);
+ }
+ catch (SocketException ex)
+ {
+ }
}
#endregion Protected Instance Methods @@ -537,6 +555,11 @@
/// The encoding to use for the packet.
/// </summary>
private Encoding m_encoding = Encoding.Default;
+
+ /// <summary>
+ /// The HopLimot (MulticastTTL) of the packet.
+ /// </summary>
+ private int m_multicastHopLimit = 1;
#endregion Private Instance Fields
}
-----
#- Björn Riemer
#- FOKUS - Fraunhofer Institute for Open Communication Systems
#- -Sensor Applications and Networks -
#- Kaiserin-Augusta-Allee 31
#- 10589 Berlin, Germany
#- phone: +49 30 3463-7747
#- fax: +49 30 3463-8000
#- email: bjoern.riemer@fokus.fraunhofer.de
#- http://www.fokus.fraunhofer.de