Пример #1
0
        /// <summary>
        /// Attempts a connection to a server, provided we are not currently backing off from an offline server.
        /// </summary>
        public override void Connect()
        {
            if (this.MarkManager.RemoveExpiredMarks().IsValidMarkWindow() == true) {
                this.MarkManager.Mark();

                if (this.Options.Hostname != null && this.Options.Port != 0) {
                    try {
                        this.ReceivedBuffer = new byte[this.BufferSize];
                        this.PacketStream = new PacketStream();

                        this.SequenceNumber = 0;

                        this.ConnectionState = ConnectionState.ConnectionConnecting;

                        this.Client = new System.Net.Sockets.TcpClient {
                            NoDelay = true
                        };

                        this.Client.BeginConnect(this.Options.Hostname, this.Options.Port, this.ConnectedCallback, this);
                    }
                    catch (SocketException se) {
                        this.Shutdown(se);
                    }
                    catch (Exception e) {
                        this.Shutdown(e);
                    }
                }
            }
        }
Пример #2
0
 protected TcpClient()
     : base()
 {
     this.ReceivedBuffer = new byte[this.BufferSize];
     this.PacketStream = new PacketStream();
 }