コード例 #1
0
ファイル: CommHelper.cs プロジェクト: agilecomputing/nomads
        public bool init(TcpClient client)
        {
            if (client == null) {
                return false;
            }

            _tcpClient = client;

            try {
                Stream stream = _tcpClient.GetStream();

                // !! DO NOT instantiate the LineReaderInputStream with a BufferedStream
                // this can cause very odd behaviour
                _inputReader = new LineReaderInputStream(stream);

                BufferedStream buffStream = new BufferedStream(stream);
                _outputWriter = new StreamWriter(buffStream);

                return true;
            }
            catch (SocketException ex) {
                // close the socket if an exception occurs getting its  stream
                closeConnection();                        
                if (_debug) {
                    Console.WriteLine(ex.ToString());
                }
            }

            return false;  
        }
コード例 #2
0
        public bool init(TcpClient client)
        {
            if (client == null)
            {
                return(false);
            }

            _tcpClient = client;

            try {
                Stream stream = _tcpClient.GetStream();

                // !! DO NOT instantiate the LineReaderInputStream with a BufferedStream
                // this can cause very odd behaviour
                _inputReader = new LineReaderInputStream(stream);

                BufferedStream buffStream = new BufferedStream(stream);
                _outputWriter = new StreamWriter(buffStream);

                return(true);
            }
            catch (SocketException ex) {
                // close the socket if an exception occurs getting its  stream
                closeConnection();
                if (_debug)
                {
                    Console.WriteLine(ex.ToString());
                }
            }

            return(false);
        }
コード例 #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _tcpClient.Close();
                _inputReader.Dispose();
                _outputWriter.Dispose();

                _tcpClient    = null;
                _inputReader  = null;
                _outputWriter = null;
            }
        }
コード例 #4
0
ファイル: CommHelper.cs プロジェクト: agilecomputing/nomads
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _tcpClient.Close();
                _inputReader.Dispose();
                _outputWriter.Dispose();

                _tcpClient = null;
                _inputReader = null;
                _outputWriter = null;
            }
        }