コード例 #1
0
ファイル: UDPSocketManager.cs プロジェクト: windygu/EPICS.NET
 /// <summary>
 /// The stop listen.
 /// </summary>
 /// <param name="socket">
 /// The socket.
 /// </param>
 /// <param name="listenFunc">
 /// The listen func.
 /// </param>
 public static void StopListen(Socket socket, udpReceiver listenFunc)
 {
     lock (ListenFunctions)
     {
         ListenFunctions[socket.LocalEndPoint.ToString()].Remove(listenFunc);
     }
 }
コード例 #2
0
ファイル: UDPSocketManager.cs プロジェクト: windygu/EPICS.NET
        /// <summary>
        /// The listen.
        /// </summary>
        /// <param name="ipe">
        /// The ipe.
        /// </param>
        /// <param name="listenFunc">
        /// The listen func.
        /// </param>
        public static void Listen(IPEndPoint ipe, udpReceiver listenFunc)
        {
            var newListenfunction = false;

            lock (ListenFunctions)
            {
                if (ListenFunctions.ContainsKey(ipe.ToString()))
                {
                    ListenFunctions[ipe.ToString()].Add(listenFunc);
                }
                else
                {
                    newListenfunction = true;
                    ListenFunctions.Add(ipe.ToString(), new List <udpReceiver> {
                        listenFunc
                    });
                }
            }

            if (newListenfunction)
            {
                var newListener = new Thread(ListenSocket);
                newListener.IsBackground = true;
                newListener.Start(SocketDict[ipe.ToString()]);

                // ThreadPool.QueueUserWorkItem(ListenSocket, SocketDict[ipe.ToString()]);
            }
        }
コード例 #3
0
ファイル: UDPSocketManager.cs プロジェクト: windygu/EPICS.NET
 /// <summary>
 /// The listen.
 /// </summary>
 /// <param name="socket">
 /// The socket.
 /// </param>
 /// <param name="listenFunc">
 /// The listen func.
 /// </param>
 public static void Listen(Socket socket, udpReceiver listenFunc)
 {
     Listen((IPEndPoint)socket.LocalEndPoint, listenFunc);
 }
コード例 #4
0
ファイル: UDPSocketManager.cs プロジェクト: windygu/EPICS.NET
 /// <summary>
 /// The listen.
 /// </summary>
 /// <param name="port">
 /// The port.
 /// </param>
 /// <param name="listenFunc">
 /// The listen func.
 /// </param>
 public static void Listen(int port, udpReceiver listenFunc)
 {
     Listen(new IPEndPoint(IPAddress.Any, port), listenFunc);
 }
コード例 #5
0
		/// <summary>
		/// The stop listen.
		/// </summary>
		/// <param name="socket">
		/// The socket.
		/// </param>
		/// <param name="listenFunc">
		/// The listen func.
		/// </param>
		public static void StopListen(Socket socket, udpReceiver listenFunc)
		{
			lock (ListenFunctions)
			{
				ListenFunctions[socket.LocalEndPoint.ToString()].Remove(listenFunc);
			}
		}
コード例 #6
0
		/// <summary>
		/// The listen.
		/// </summary>
		/// <param name="socket">
		/// The socket.
		/// </param>
		/// <param name="listenFunc">
		/// The listen func.
		/// </param>
		public static void Listen(Socket socket, udpReceiver listenFunc)
		{
			Listen((IPEndPoint)socket.LocalEndPoint, listenFunc);
		}
コード例 #7
0
		/// <summary>
		/// The listen.
		/// </summary>
		/// <param name="port">
		/// The port.
		/// </param>
		/// <param name="listenFunc">
		/// The listen func.
		/// </param>
		public static void Listen(int port, udpReceiver listenFunc)
		{
			Listen(new IPEndPoint(IPAddress.Any, port), listenFunc);
		}
コード例 #8
0
		/// <summary>
		/// The listen.
		/// </summary>
		/// <param name="ipe">
		/// The ipe.
		/// </param>
		/// <param name="listenFunc">
		/// The listen func.
		/// </param>
		public static void Listen(IPEndPoint ipe, udpReceiver listenFunc)
		{
			var newListenfunction = false;
			lock (ListenFunctions)
			{
				if (ListenFunctions.ContainsKey(ipe.ToString()))
				{
					ListenFunctions[ipe.ToString()].Add(listenFunc);
				}
				else
				{
					newListenfunction = true;
					ListenFunctions.Add(ipe.ToString(), new List<udpReceiver> { listenFunc });
				}
			}

			if (newListenfunction)
			{
				var newListener = new Thread(ListenSocket);
				newListener.IsBackground = true;
				newListener.Start(SocketDict[ipe.ToString()]);

				// ThreadPool.QueueUserWorkItem(ListenSocket, SocketDict[ipe.ToString()]);
			}
		}