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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:51:36+00:00 2026-06-01T11:51:36+00:00

I got a working server in C# and a working client in Java (Android).

  • 0

I got a working server in C# and a working client in Java (Android). It’s totally working, but the connection itself is only one-wayed. Only the client can send data to the server. I tried to make the connection two-sided, but the code not working by an unknown reason.

Where I do it wrong?

C#- server

public void SendBack(string message, NetworkStream stream)
{
  if (stream.CanWrite)
  {
    byte[] candy = Encoding.ASCII.GetBytes(message + ";");

    stream.Write(candy, 0, candy.Length);
    stream.Flush();

    Console.WriteLine("[SENT] " + message);
  }
  else { Console.WriteLine("ERROR! CANNOT WRITE ON NETWORKSTREAM!"); }
}

Java- client

//Creating the stream in the constructor
bReader = new BufferedReader(new InputStreamReader(gSocket.getInputStream()));

new Thread (new Runnable(){
  public void run() {
    Log.d(TAG, "Started listerner...");
    ListenServer();
  }
}).start();

//The function itself
private void ListenServer(){
  try
  {
    String inputLine = "";
    while (true){
      inputLine = bReader.readLine();
      if (inputLine != null) Log.d(TAG, "Got: " + inputLine);
    }
  }
  catch (IOException e){ Log.d(TAG, "Could not listen to sever!"); }
}

Edit: forget to mention whats the actual problem… I start the server, behaves like usual, client can send data, which the server can interpret the message. Hoverwer, if the server sends something, the client do nothing. I mean, it does not execute the

Log.d(TAG, "Got: " + inputLine);

code.

  • 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-01T11:51:38+00:00Added an answer on June 1, 2026 at 11:51 am

    It could be that the server is not sending the line-feed and/or carriage-return. BufferedReader.readLine()(link) expects it. You can construct a StreamWriter with the incoming stream, and use one of the WriteLine methods.

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

Sidebar

Related Questions

I've got a working SOAP::Lite client. It works against an established server, but so
I'm totally new to both java and java Server worlds... But I've a good
We are currently working on a client-server game in java. We used DatagramSocket to
I've got ELMAH working on my (Cassini) development server, and was quite happy with
I am building a client server application using Java Sockets (in Windows XP). For
Currently I'm working on a Server-Client system which will be the backbone of my
I am working on a java client for WCF, and have the template worked
Got a problem about server-client: When server is running, if I want to make
Right now I've got a simple TCP server/client. I have it set up so
I'm looking for a good, high-level python ftp client/server library. I'm working on a

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.