public bool Connect() { if (this._buffer == null) { this._buffer = new byte[0x2800]; } if (this._virtualScreen == null) { this._virtualScreen = new WTF.Framework.VirtualScreen(this._vsWidth, this._vsHeight, 1, 1); } if (this._callBackReceive == null) { this._callBackReceive = new AsyncCallback(this.ReadFromStream); } if (this._callBackSend == null) { this._callBackSend = new AsyncCallback(this.WriteToStream); } this._serverEcho = false; this._clientInitNaws = false; this._firstResponse = true; this._nawsNegotiated = false; this._forceLogout = false; if (this._tcpClient != null) { return(true); } try { TcpClient client = new TcpClient(this._hostName, this._port) { ReceiveTimeout = this._timeoutReceive, SendTimeout = this._timeoutSend, NoDelay = true }; this._tcpClient = client; this._tcpClient.GetStream().BeginRead(this._buffer, 0, this._buffer.Length, this._callBackReceive, null); return(true); } catch { this._tcpClient = null; return(false); } }
public void Close() { if (this._tcpClient != null) { try { this._tcpClient.GetStream().Close(); this._tcpClient.Close(); this._tcpClient = null; } catch { this._tcpClient = null; } } this._virtualScreen = null; this._buffer = null; this._callBackReceive = null; this._callBackSend = null; this._forceLogout = false; }