public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                log.Error("Connect Error :remoteEndPoint  is null.");
                throw new ArgumentNullException("remoteEndPoint is null");
            }

            m_RemoteEndPoint = remoteEndPoint;
            var dnsEndPoint = remoteEndPoint as DnsEndPoint;

            if (dnsEndPoint != null)
            {
                var hostName = dnsEndPoint.Host;

                if (!string.IsNullOrEmpty(hostName))
                {
                    HostName = hostName;
                }
            }

            if (m_InConnecting)
            {
                log.Error("The socket is connecting, cannot connect again!");
                return;
                //throw new Exception("The socket is connecting, cannot connect again!");
            }

            if (Client != null)
            {
                log.Error("The socket is connected, you needn't connect again!");
                throw new Exception("The socket is connected, you needn't connect again!");
            }


            //If there is a proxy set, connect the proxy server by proxy connector
            if (Proxy != null)
            {
                Proxy.Completed += new EventHandler <ProxyEventArgs>(Proxy_Completed);
                Proxy.Connect(remoteEndPoint);
                m_InConnecting = true;
                return;
            }

            m_InConnecting = true;

            //WindowsPhone doesn't have this property
#if SILVERLIGHT && !WINDOWS_PHONE
            remoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null);
#elif WINDOWS_PHONE
            remoteEndPoint.ConnectAsync(ProcessConnect, null);
#else
            remoteEndPoint.ConnectAsync(LocalEndPoint, ProcessConnect, null);
#endif
        }
Exemple #2
0
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }

            if (m_InConnecting)
            {
                throw new Exception("The socket is connecting, cannot connect again!");
            }

            if (Client != null)
            {
                throw new Exception("The socket is connected, you needn't connect again!");
            }

            //If there is a proxy set, connect the proxy server by proxy connector
            if (Proxy != null)
            {
                Proxy.Completed += new EventHandler <ProxyEventArgs>(Proxy_Completed);
                Proxy.Connect(RemoteEndPoint);
                m_InConnecting = true;
                return;
            }

            m_InConnecting = true;

            remoteEndPoint.ConnectAsync(LocalEndPoint, ProcessConnect, null);
        }
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }

            var dnsEndPoint = remoteEndPoint as DnsEndPoint;

            if (dnsEndPoint != null)
            {
                var hostName = dnsEndPoint.Host;

                if (!string.IsNullOrEmpty(hostName))
                {
                    HostName = hostName;
                }
            }

            if (m_InConnecting)
            {
                throw new Exception("The socket is connecting, cannot connect again!");
            }

            if (Client != null)
            {
                throw new Exception("The socket is connected, you needn't connect again!");
            }

            m_InConnecting = true;

            remoteEndPoint.ConnectAsync(LocalEndPoint, ProcessConnect, null);
        }
        // Token: 0x060008C3 RID: 2243 RVA: 0x0001DC74 File Offset: 0x0001BE74
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }
            DnsEndPoint dnsEndPoint = remoteEndPoint as DnsEndPoint;

            if (dnsEndPoint != null)
            {
                string host = dnsEndPoint.Host;
                if (!string.IsNullOrEmpty(host))
                {
                    this.HostName = host;
                }
            }
            if (this.m_InConnecting)
            {
                throw new Exception("The socket is connecting, cannot connect again!");
            }
            if (base.Client != null)
            {
                throw new Exception("The socket is connected, you needn't connect again!");
            }
            if (base.Proxy != null)
            {
                base.Proxy.Completed += this.Proxy_Completed;
                base.Proxy.Connect(remoteEndPoint);
                this.m_InConnecting = true;
                return;
            }
            this.m_InConnecting = true;
            remoteEndPoint.ConnectAsync(this.LocalEndPoint, new ConnectedCallback(this.ProcessConnect), null);
        }
Exemple #5
0
        public override void Connect(EndPoint remoteEndPoint)
        {
            if (remoteEndPoint == null)
            {
                throw new ArgumentNullException("remoteEndPoint");
            }

            if (m_InConnecting)
            {
                throw new Exception("The socket is connecting, cannot connect again!");
            }

            if (Client != null)
            {
                throw new Exception("The socket is connected, you needn't connect again!");
            }

            //If there is a proxy set, connect the proxy server by proxy connector
            if (Proxy != null)
            {
                Proxy.Completed += new EventHandler <ProxyEventArgs>(Proxy_Completed);
                Proxy.Connect(RemoteEndPoint);
                m_InConnecting = true;
                return;
            }

            m_InConnecting = true;

            //WindowsPhone doesn't have this property
#if SILVERLIGHT && !WINDOWS_PHONE
            remoteEndPoint.ConnectAsync(ClientAccessPolicyProtocol, ProcessConnect, null);
#elif WINDOWS_PHONE
            remoteEndPoint.ConnectAsync(ProcessConnect, null);
#else
            remoteEndPoint.ConnectAsync(LocalEndPoint, ProcessConnect, null);
#endif
        }