Example #1
0
        //////////////////////////////////////////////////////////////////////
        // Connection accept an incoming connection

        protected virtual void AcceptFrom(Socket socket)
        {
            this.Input  = new Global.Buffer();
            this.Output = new Global.Buffer();
            this.Socket = socket;

            OnConnected();
        }
Example #2
0
        //////////////////////////////////////////////////////////////////////
        // Connection close

        public virtual void Disconnect()
        {
            lock (this)
            {
                if (this.Socket != null)
                {
                    this.Socket.Close();
                }
                this.Socket = null;
            }

            if (ReadIoOver != null)
            {
                ReadIoOver.AsyncWaitHandle.WaitOne();
            }
            if (WriteIoOver != null)
            {
                WriteIoOver.AsyncWaitHandle.WaitOne();
            }

            this.Input = this.Output = null;
        }
Example #3
0
        //////////////////////////////////////////////////////////////////////
        // Connection accept an incoming connection
        protected virtual void AcceptFrom(Socket socket)
        {
            this.Input = new Global.Buffer();
            this.Output = new Global.Buffer();
            this.Socket = socket;

            OnConnected();
        }
Example #4
0
        //////////////////////////////////////////////////////////////////////
        // Connection close
        public virtual void Disconnect()
        {
            lock (this)
            {
                if (this.Socket != null) this.Socket.Close();
                this.Socket = null;
            }

            if (ReadIoOver != null) ReadIoOver.AsyncWaitHandle.WaitOne();
            if (WriteIoOver != null) WriteIoOver.AsyncWaitHandle.WaitOne();

            this.Input = this.Output = null;
        }
Example #5
0
        //////////////////////////////////////////////////////////////////////
        // Connection connect to
        public virtual SocketError ConnectTo(IPAddress address, int port)
        {
            try
            {
                this.Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                this.Socket.Connect(address, port);

                this.Input = new Global.Buffer();
                this.Output = new Global.Buffer();

                return SocketError.Success;
            }
            catch (SocketException exception)
            {
                return (SocketError)exception.ErrorCode;
            }
            finally
            {
                this.Input = this.Output = null;
            }
        }