Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8723023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:32:11+00:00 2026-06-13T07:32:11+00:00

I am building an application where I have a server and a client that

  • 0

I am building an application where I have a server and a client that talk to each other –over telnet. (via socket). The server program is monitoring a tank of some gass, and sends temperature level and preassure level via socket to the accepted clients.

I have managed to get the client and server to talk to each other when I write stuff –in telnet–, but…
I need some help to handle the data that I send.

I have made a loginscript to determine if the user is a valid user or not.
So I can write two words like “myname” “space” “mypassword” and I get a green light and returns a valid user.
But when I only write one word, and hit enter, it gives me:
Exeption in thread… java.lang.Array.IndexOutOfBoundsExeption EXEPT for when I write exit or logout!

(All users are hardcoded in the script for ease of use for testing. (The login script works fine by it self, and returns valid user = false when I write something wrong.)
Here is my code. Some pseudo code is added since I am not 100% sure of what to do…;)

String telNetCommand = dataIn.readLine();
            System.out.println(telNetCommand);

            String dataInArray[] = telNetCommand.split(" ");

            user.isValid(dataInArray[0], dataInArray[1]);

            if (dataInArray[1] == "\n") {
            //Ignore login request and continue telnet-logging?
            }

The client application has a button for each command, like:

“Send me every n’th data”, or “Send me a batch of data every n’th second. If command equals exit, or logout – > break operation….

// --------------// USER INPUT FROM CLIENT APP //--------------------------//

            // --------------// CONTINUE ? //----------------------------//
            if (command.equals("CONTINUE")) {
                continueSession();
                else  {    //..Kill session
                }   
            }

            // --------------// SKIP <N> //----------------------------//
            if (command.equals("SKIP_N")) {
                skipEveryNthData();
            }

            // --------------// BATCH <N> //---------------------------//
            if (command.equals("BATCH_N")) {
                batchEveryNthData();
            }

            // --------------// LOGG OUT #1 //-------------------------//
            if (command.equals("logout") || command.equals("exit")) {
                break;
            }

Maybe I am getting a bit confused now, but I think that I need to put all data into an array, and check

if
dataInArray[0] == "CONTINUE"
dataInArray[0] == "SKIP_N", or
dataInArray[0] == "BATCH_N" 
(then send some data back)...

and…

if dataInArray[1] == "enter" ("\n") execute the single word commands ...??
if dataInArray[0] == "LOG_IN" or "PASSWORD" check if valid user is true..

Thanks for any help, and/or tips! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:32:12+00:00Added an answer on June 13, 2026 at 7:32 am

    Thanks guys. I don’t get any errors now… And here is what I ended up doing.
    I had to set it == 2 in order not to get any errors.

    while (true) {
                String telnetCommand = dataIn.readLine();
    
                System.out.println(telnetCommand);
    
                String dataInArray[] = telnetCommand.split(" ");
    
                if (dataInArray.length == 2) {
                    user.isValid(dataInArray[0], dataInArray[1]);
                }
    
                if (dataInArray.length < 2) {
                    if (telnetCommand.equals("CONTINUE")) {
                        continueThisSession();
                        System.out.println("Running method continueThisSession");
                    }
    
                    if (telnetCommand.equals("SKIP_N")) {
                        skipEveryNthData();
                        System.out.println("Running method skipEveryNthData");
                    }
    
                    if (telnetCommand.equals("BATCH_N")) {
                        batchEveryNthData();
                        System.out.println("Running method batchEveryNthData");
                    }
    
                    if (telnetCommand.equals("logout")  || telnetCommand.equals("exit")) {
                        break;
                    }
                }
            }
    

    Peace 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I'm building an application that will have over 30 models, and I want
I am building a web application that have several requirements for the client: 1.
I am building a client side application that will use a SQL Server back
so i am building a client server application and i have to chose how
I have a client-server application that works kinda like a messenger, the application is
i'm building an android application which have a chat. in this chat i each
I am building a web application and have been told that using object oriented
I am building an application that will have a model that belongs_to another model
I am building a Rails application that contains Developer s who have Application s.
I'm building an application where I'll have a SwingWorker thread that in itself spins

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.