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; }
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); }
protected virtual void Dispose(bool disposing) { if (disposing) { _tcpClient.Close(); _inputReader.Dispose(); _outputWriter.Dispose(); _tcpClient = null; _inputReader = null; _outputWriter = null; } }