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 9043327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:42:39+00:00 2026-06-16T10:42:39+00:00

I have yet another question about my push server. For some reason the server

  • 0

I have yet another question about my push server. For some reason the server will only accept one connection during it’s lifetime. Even after the first connection has been closed, the server won’t do anything. I have a suspicion that the thread isn’t being spawned because it’s not refusing the connection.

Here is the code to the server: http://docs.oracle.com/javase/tutorial/networking/sockets/examples/KKMultiServer.java

I used the example because it’s just what I needed. I left this code unchanged. It’s the thread I really worked with…

import java.net.*;
import java.io.*;

public class KKMultiServerThread extends Thread {
    private Socket socket = null;

    public KKMultiServerThread(Socket socket) {
            super("KKMultiServerThread");
            this.socket = socket;
    }

    public void run() {
            try {
                    final PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
                    BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                    String inputLine, outputLine;
                    out.println("connected");
                    boolean loggedin = false;
                    String username="";
                    String password="";
                    String deviceid="";
                    while (true) {
                    //deal with login handshake
                            if ((inputLine = in.readLine()) == null) inputLine="";
                            if (!loggedin) {
                                   Logs the user in...
                                   Also does things with files and keeps reading and writing to the client...
                    }
                    out.close();
                    in.close();
                    socket.close();
            } catch (IOException e) {
                    e.printStackTrace();
            }
    return;
    }
}

What could be going wrong? I close the socket and all of the streams like I should but even then it should still work, shouldn’t it?

Thank you for the continued support!

  • 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-16T10:42:40+00:00Added an answer on June 16, 2026 at 10:42 am

    if ((inputLine = in.readLine()) == null) inputLine=””;

    This line of code is grade A nonsense. If inputLine is null, the peer has closed the socket, and you must exit the loop and close the socket yourself. At present you are ignoring the EOS condition and looping forever.

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

Sidebar

Related Questions

yet another basic question ... I have an app that takes about 4-5 secs
Yet another question about which NoSQL to choose. However, I haven't found yet someone
Yet another question about classes as Im new to OOP. I am creating a
Sorry for yet another question about EF4 context lifespan, but I've been wondering about
Yet another question about updating from background threads. To get to the point: In
I have yet another issue which the answer is eluding me. I wish to
After getting a helpful answer here , I have run into yet another problem:
I have searched online for a solution, but have yet to find one that
Okay this may be a simple question but I have yet to come with
This is yet another EXC_BAD_ACCESS question. Although I've done my homework and am certain

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.