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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:13:01+00:00 2026-06-13T08:13:01+00:00

I am making a java applet that has basic chat functionality (you can send/recieve

  • 0

I am making a java applet that has basic chat functionality (you can send/recieve messages). I have made a separate thread to handle the connection on the client version, and the server also makes a thread for every connected client.

in the run() method of the client i have a while loop to read any messages recieved:

while (state == ConnectionState.CONNECTED) {
   out.println("Hello Server");
   out.flush();
   String input = in.readLine();
   System.out.println(input);
   if(input == null){
      connectionClosedFromOtherSide();
   }
   else {
      received(input);
      System.out.println(String.format("Recieved something: %s", input));
   }
}

Here out is my PrintWriter and in my BufferedReader. For debugging purposes I put the ‘hello server’ here. This code works fine, but the problem is the sendtext() method:

synchronized private void sendText(String tosend) {
   if(out != null && state == ConnectionState.CONNECTED){
      out.print(tosend);
      out.flush();
      System.out.println(String.format("sending %s to server", tosend));
   }
}

For some reason, if i call this method, it isn’t recieved on the server side. (however the console does show that it is sent)

Can anyone please help me out with this?

  • 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-13T08:13:02+00:00Added an answer on June 13, 2026 at 8:13 am

    Client side, each

    String input = in.readLine(); // read until newline
    

    should be, on server side, balanced by

    out.println( tosend ); // print the newline expected by the client
    

    out.flush() don’t send a newline.

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

Sidebar

Related Questions

I have a Java Applet that I'm making some edits to and am running
I'm making a Java program that can solve the roots using the quadratic equation
We currently have a Java applet that generates a lot of data and uploads
I have a Java Applet that uses AWT. In some (rare) circumstances, the platform
I'm making a Java console application that needs to send an HTTP request to
I am making a Java Applet right now. I have compiled with Java 1.5.
Hey everyone I am making my first applet for java today. I have been
I have a working Java app that can find the most recently created file
I am making an applet in Java that will be embedded into a web
I am making a java applet player. It includes Java.Media package, and I am

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.