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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:06:08+00:00 2026-06-07T17:06:08+00:00

I am developing an app that connects to a java server through a TCP

  • 0

I am developing an app that connects to a java server through a TCP socket. For some reason the client/app keeps getting stuck at the //HERE.

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.net.UnknownHostException;

import android.util.Log;

class ClientConnectToServer
{Socket clientSocket;

      public ClientConnectToServer()
     { try {
        clientSocket = new Socket("10.0.2.2", 9000);
    } catch (UnknownHostException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

      public String sendMessage(String message)
      {
try{        clientSocket = new Socket("10.0.2.2", 9000);

          String modifiedSentence;
          DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());
          BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
          outToServer.writeBytes(message + '\n');
          modifiedSentence = inFromServer.readLine();
          outToServer.close();
          inFromServer.close();
              //HERE
          clientSocket.close();
          Log.v(modifiedSentence, modifiedSentence);
          return modifiedSentence;}
catch(Exception e)
{
    return "";}

      }
}

Thanks for any help.

  • 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-07T17:06:09+00:00Added an answer on June 7, 2026 at 5:06 pm

    Not possible. At that point the socket is already closed due to both prior closes, so there is nothing for that line of code to do. More likely you are blocked at the logging line for some reason.

    When closing a socket you should close the output stream or writer you have wrapped around its out stream. That flushes it and closes the input stream and the socket. Don’t close anything else.

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

Sidebar

Related Questions

I'm developing an app, that connects to a ranking server, to get the current
I am developing an app that connects to Google Calendar in Java. So far
I am developing an app that should connect to some server machine and access
I am developing an app under Java that has to call at some point
I'm developing an app (Flash/AS3) that connects to Facebook. After the user logs in
I'm developing an ASP.NET app (C#) that connect to SQL Server 2008 using ADO.NET
I am developing an app that has java files and php files. The java
I'm developing an app that starts a System.Threading.Timer which does some fairly rapid reading/writing
I am developing an Android app that connects to the Facebook Open Graph via
I am developing a web app that connects to a SQL 2000 database. Everything

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.