示例#1
0
        public override void Connect()
        {
            try
            {
                if (this.UdpClient != null)
                {
                    try
                    {
                        this.UdpClient.Close();
                        this.UdpClient.Client.Dispose();
                    }
                    catch (Exception)
                    {
                        // ignore
                    }
                }
                this.UdpClient = new UdpClient(LocalEndpoint);
                this.UdpClient.Client.DontFragment = true;
                //this.UdpClient.Client.NoDelay = true;
                //this.UdpClient.Client.SendBufferSize = 0;
            }
            catch (SocketException sex)
            {
                Console.WriteLine("Connect() - failed with exception: {0}", sex.ToString());
                throw new ConnectionErrorException(this.Host, this.Port);
            }

            if (KNXReceiver == null || KNXSender == null)
            {
                KNXReceiver = new KNXReceiverTunneling(this, this.UdpClient, LocalEndpoint);
                KNXSender   = new KNXSenderTunneling(this, this.UdpClient, RemoteEndpoint);
            }
            else
            {
                ((KNXReceiverTunneling)KNXReceiver).UdpClient = this.UdpClient;
                ((KNXSenderTunneling)KNXSender).UdpClient     = this.UdpClient;
            }

            KNXReceiver.Start();

            try
            {
                ConnectRequest();
            }
            catch (Exception)
            {
                // ignore
            }
        }
示例#2
0
        public override void Connect()
        {
            try
            {
                if (this.UdpClient != null)
                {
                    try
                    {
                        this.UdpClient.Close();
                        this.UdpClient.Client.Dispose();
                    }
                    catch (Exception)
                    {
                        // ignore
                    }
                }
                this.UdpClient = new UdpClient(LocalEndpoint);
                this.UdpClient.Client.DontFragment = true;
                //this.UdpClient.Client.NoDelay = true;
                //this.UdpClient.Client.SendBufferSize = 0;
            }
            catch (SocketException sex)
            {
				Console.WriteLine ("Connect() - failed with exception: {0}", sex.ToString ());
                throw new ConnectionErrorException(this.Host, this.Port);
            }

            if (KNXReceiver == null || KNXSender == null)
            {
                KNXReceiver = new KNXReceiverTunneling(this, this.UdpClient, LocalEndpoint);
                KNXSender = new KNXSenderTunneling(this, this.UdpClient, RemoteEndpoint);
            }
            else
            {
                ((KNXReceiverTunneling)KNXReceiver).UdpClient = this.UdpClient;
                ((KNXSenderTunneling)KNXSender).UdpClient = this.UdpClient;
            }

            KNXReceiver.Start();

            try
            {
                ConnectRequest();
            }
            catch (Exception)
            {
                // ignore
            }
        }