private void ConnectToRemoteServer(object threadParams)
        {
            SocketThreadInfo threadInfo = (SocketThreadInfo) threadParams;

                Connection = new TcpClient();

                try
                {
                    ConnectedStatus = ConnectionStatus.Connecting;
                    Connection.Connect(new IPEndPoint(threadInfo.ip, threadInfo.port));

                    ConnectedStatus = ConnectionStatus.Authenticating;
                    EncryptedStream = new EncryptedNetworkStream(Connection.GetStream(), threadInfo.password, true);

                    ConnectedStatus = ConnectionStatus.Connected;

                    DisplayOpenMenuWithRemoteSettings();

                    ProcessData();

                } catch (Exception ex) {
                }

                Connection = null;
        }
        private void ListenerThread(object threadParams)
        {
            SocketThreadInfo threadInfo = (SocketThreadInfo) threadParams;

                Server = new TcpListener(IPAddress.Any, threadInfo.port);
                Server.Start();

                while (true)
                {
                    ListeningStatus = ListenStatus.Listening;

                    Connection = Server.AcceptTcpClient();
                    ConnectedStatus = ConnectionStatus.Connecting;

                    try
                    {
                        ListeningStatus = ListenStatus.Authenticating;
                        ConnectedStatus = ConnectionStatus.Authenticating;

                        EncryptedStream = new EncryptedNetworkStream(Connection.GetStream(), threadInfo.password, false);

                        ListeningStatus = ListenStatus.Connected;
                        ConnectedStatus = ConnectionStatus.Connected;

                        ProcessData();
                    } catch (Exception ex) {
                    }

                    Connection = null;
                }
        }