rv.PJLinkConnection.initConnection C# (CSharp) Method

initConnection() private method

private initConnection ( ) : bool
return bool
        private bool initConnection()
        {
            try
            {
                if (_client == null || !_client.Connected)
                {
                    _client = new TcpClient(_hostName, _port);
                    _stream = _client.GetStream();
                    byte[] recvBytes = new byte[_client.ReceiveBufferSize];
                    int bytesRcvd = _stream.Read(recvBytes, 0, (int)_client.ReceiveBufferSize);
                    string retVal = Encoding.ASCII.GetString(recvBytes, 0, bytesRcvd);
                    retVal = retVal.Trim();

                    if(retVal.IndexOf("PJLINK 0") >= 0)
                    {
                        _useAuth = false;  //pw provided but projector doesn't need it.
                        return true;
                    }
                    else if (retVal.IndexOf("PJLINK 1 ") >= 0)
                    {
                        _pjKey = retVal.Replace("PJLINK 1 ", "");
                        return true;
                    }
                }
                return false;
            }
            catch(Exception){
                return false;
            }
        }