Fixed the licensing statements - I had erroneously marked the files as covered by...
[lwes-dotnet/github-mirror.git] / Org.Lwes / Listener / UnicastEventListener.cs
blob39d7f2bea06f89afc8b5c5b7b25506a2f160ff43
1 //
2 // This file is part of the LWES .NET Binding (LWES.net)
3 //
4 // COPYRIGHT (C) 2009, Phillip Clark (cerebralkungfu[at*g mail[dot*com)
5 // original .NET implementation
6 //
7 // LWES.net is free software: you can redistribute it and/or modify
8 // it under the terms of the Lesser GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
12 // LWES.net is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the Lesser GNU General Public License
18 // along with LWES.net. If not, see <http://www.gnu.org/licenses/>.
20 namespace Org.Lwes.Listener
22 using System;
23 using System.Collections.Generic;
24 using System.Linq;
25 using System.Net;
26 using System.Net.Sockets;
27 using System.Text;
29 using Org.Lwes.DB;
30 using Org.Lwes.Properties;
32 /// <summary>
33 /// Implementation of the IEventListener for listening to multicast events.
34 /// </summary>
35 public sealed class UnicastEventListener : EventListenerBase
37 #region Methods
39 /// <summary>
40 /// Initializes the event listener.
41 /// </summary>
42 /// <param name="db"></param>
43 /// <param name="address"></param>
44 /// <param name="port"></param>
45 /// <param name="parallel"></param>
46 /// <param name="garbageHandling"></param>
47 public void Initialize(IEventTemplateDB db
48 , IPAddress address
49 , int port
50 , bool parallel
51 , ListenerGarbageHandling garbageHandling)
53 if (IsInitialized) throw new InvalidOperationException(Resources.Error_AlreadyInitialized);
55 base.Initialize(db, new IPEndPoint(address, port), parallel, garbageHandling,
56 (s, e) =>
58 s.SetSocketOption(SocketOptionLevel.Udp, SocketOptionName.NoDelay, 1);
59 s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
60 s.Bind(e);
61 });
64 #endregion Methods