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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:15:46+00:00 2026-06-16T13:15:46+00:00

using this code: Java Server side: … out = new PrintWriter(this.client.getOutputStream(), true); … public

  • 0

using this code:

Java Server side:

...
out = new PrintWriter(this.client.getOutputStream(), true);
...
public void sendMsg(String msg) {
    out.println(msg);
    //out.flush(); // we don't flush manually because there is auto flush true
}

C# Client side:

    while(connected) {
        int lData = myStream.Read(myBuffer, 0, client.ReceiveBufferSize);
        String myString = Encoding.UTF8.GetString(myBuffer);
        myString = myString.Substring(0, lData);
        myString = myString.Substring(0, myString.Length-2);
        addToQueue(myString);
    }

variable myString have many messages that server should send them one by one like

hello \r\t hello \r\t ...

they should come separately like

hello \r\t
hello \r\t ...

which means when i wait one by one they come instantly all of them in a row, how can i make it to send one by one in separate flush.

Note I send 30~ messages in a row in one second (1s), i want them separate.

  • 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-16T13:15:47+00:00Added an answer on June 16, 2026 at 1:15 pm

    TCP supports a stream of bytes. This means you have no control how the data arrives regardless of how you send it. (Other than it will comes as bytes) You should rethink your protocol if you depend on it coming in any particular manner.

    You can reduce the amount of bunching of data but all this does is reduce latency at the cost of throughput and should never be relied upon. This can be reduce (but not eliminated) by turning off Nagle and reducing co-alessing setting in your TCP driver if you can change these.

    i want them separate.

    You can want it but TCP does not support messages as you would want them.


    The solution in you case is for your reader to match your writers protocol. You send lines so you should read lines at a time, e.g. BufferedReader.readLine(), not blocks of whatever data happens to be in the buffer.

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

Sidebar

Related Questions

I have a Java-based server side and a flex client side using Spring BlazeDS
I have a client server application where I am using java serversocket(server side) and
I am using java for my server side application and phonegap for my client
I am using iTextSharp in VB.net. I have this piece of code from java
While using this code to serialize an object: public object Clone() { var serializer
I am using java sockets for communication. On the client side I have some
cI'm using this code to upload a jsonarray to a server (maybe there is
Using this code, i am able to send a notification to my own device.
Using this code to zip a folder and it works perfect on small files
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:

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.