JLChen
2020-12-09 e87985ec1dcb69beedaf9f95e8e7aba14b7c08d6
HDL_ON/DAL/DriverLayer/UdpSocket.cs
@@ -25,7 +25,7 @@
      /// <summary>
      /// 启动Socket接收和发送功能
      /// </summary>
      public void Start (int port)
      public void Start (int port = 0)
        {
         if (IsRunning)
         {
@@ -38,13 +38,16 @@
                    busSocket.Close();
                }
            }
            _port = port;
         if (port != 0)
            _port = port;
         if (_port == 0)
            return;
            busSocket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            busSocket.EnableBroadcast = true;
            try {
                //busSocket.Bind (new IPEndPoint (IPAddress.Any, 6000));
                busSocket.Bind(new IPEndPoint(IPAddress.Any, port));
                busSocket.Bind(new IPEndPoint(IPAddress.Any, _port));
                busSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("239.0.168.188")));
         }