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

  • Home
  • SEARCH
  • 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 6697555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:28:24+00:00 2026-05-26T06:28:24+00:00

You can see my posted code here . My original problem was more or

  • 0

You can see my posted code here. My original problem was more or less solved but now I’m running into the problem described in the question title. Here’s the problem: After I enter a command on the client side of any given client, I can’t enter additional commands. The first command will work fine (minus /exit; haven’t quite figured out how that should work yet), just can’t do anything after that. For example, I can do /register (sign in) but after that nothing else. I can go into another instance of Client and list all the current users with /list as well (works), but again, after that I cannot enter additional commands – the console will not take them after the first one. Any idea what may be happening to cause this?

Here is about where I’m referring to (Code in its entirety):

while((keyboardInput = keyboardInputScanner.nextLine()) != null){
                System.out.println("Input '" + keyboardInput + "' read on client side.");
                if(keyboardInput.equals("/exit")){
                    socketOut.println("/exit");
                    socketOut.close();
                    socketIn.close();
                    serverSocket.close();
                }else{
                    socketOut.println(keyboardInput);
                }
                while((serverInput = socketIn.readLine()) != null){
                    System.out.println(serverInput);
                }
            }

I’m relatively sure it’s something to do with not breaking out of the inner while loop, but I don’t know any way around it. If I put that while loop outside of the keyboard input loop, I’ll never get anything back from the server.

  • 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-05-26T06:28:25+00:00Added an answer on May 26, 2026 at 6:28 am

    I think the problem is here:

    while((serverInput = socketIn.readLine()) != null){
        System.out.println(serverInput);
    }
    

    This will loop indefinitely (well, until the socket is closed at the other end). You therefore never get to the second iteration of the outer loop.

    You might want to either limit the response to one line, or have some other mechanism for the server to let the client know when to stop reading from socketIn (e.g. send an empty line at the end of every server response and have the client break out of the inner loop when it sees that).

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

Sidebar

Related Questions

if you can check in my code here, you can see that the umlauts
Here I posted a demo http://jsfiddle.net/LxYMv/1/ . As you can see <body> gets margin-top:10px
I can see that GD library is for images. But I can't see differences
I can see some potential difficulties with this concept but the idea is: I
I can see from the jqGrid JSON data being posted to the browser that
I had posted a question about stepping into properties Here Turned out to be
I have some simple code you can see in my fiddle . It alerts
I have the following code but can't compile it because I have a Type
Using the code posted here , I created a nice hierarchical clustering: Let's say
I can see people asking all the time whether multiple inheritance should be included

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.